python - takes exactly 1 positional argument (0 given) -
i'm trying make every time click button can run different.
counter = 0  def b_c(counter):     counter = counter + 1     if counter == 1:         print("1")     elif counter == 2:         print("2")     else:          if counter == 3:              print("3")   but get
typeerror: b_c() takes 1 positional argument (0 given)      
try this:
counter = 0  def b_c():     global counter     counter += 1     if counter == 1:         print("1")     elif counter == 2:         print("2")     else:          if counter == 3:              print("3")  b_c() b_c() b_c()   output:
1 2 3   first thing: python case sensitive, counter not equal counter. , in function can use global counter don't need pass counter button click.
Comments
Post a Comment