Python Forum
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding 1 to number
#5
(Apr-29-2017, 01:14 PM)JohnNo Wrote: #2 well i edited the code
no error but it prints nothing

       return zeroo + 1
        print(zeroo)

Of coarse it prints nothing, you return from the function before ever trying to print anything.

Aside from that, though, try to avoid global variables.  It might be a hassle at first, but it'll make your life much better later on :)

All the cool kids have posted code, so here's some from me, too:
>>> import tkinter as tk
>>> class Counter(object):
...   def __init__(self, start: int = 0):
...     self.value = start
...   def add(self) -> int:
...     if self.value < 900:
...       self.value += 1
...     print(self.value)
...     return self.value
...
>>> clicks = Counter()
>>> root = tk.Tk()
>>> tk.Button(root, text="click me!", command=clicks.add).pack()
>>> root.mainloop()
1
2
3
4
5
6
>>>
Reply


Messages In This Thread
Adding 1 to number - by JohnNo - Apr-29-2017, 12:59 PM
RE: Adding 1 to number - by wavic - Apr-29-2017, 12:59 PM
RE: Adding 1 to number - by JohnNo - Apr-29-2017, 01:14 PM
RE: Adding 1 to number - by nilamo - Apr-29-2017, 02:26 PM
RE: Adding 1 to number - by snippsat - Apr-29-2017, 01:37 PM
RE: Adding 1 to number - by Turry - Apr-29-2017, 02:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Adding an ascending number [SOLVED] AlphaInc 3 2,348 Jul-11-2021, 10:13 AM
Last Post: perfringo
  adding elements to a list that are more than a specific number Olavv 2 2,301 Mar-19-2020, 06:05 PM
Last Post: Olavv
  Adding elements to a list by number Olavv 4 3,087 Mar-08-2020, 11:16 AM
Last Post: ndc85430
  Adding markers to Folium map only adding last element. tantony 0 2,238 Oct-16-2019, 03:28 PM
Last Post: tantony
  naming images adding to number within multiple functions Bmart6969 0 1,989 Oct-09-2019, 10:11 PM
Last Post: Bmart6969
  Adding a line number to an lxml Element vindy 0 3,483 Mar-08-2019, 08:34 PM
Last Post: vindy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020