I am calling a counter function. Every time I call this function, the print('counter: ', counter) increases as it should. However, python does not go in to read any of the if/elif statements. It always jumps to the else statement and prints 'this is the beginning'.
counter = 0
def counter():
counter += 1
print('counter: ', counter)
if end_indication == 'Yes':
print('this is the end')
else:
pass
if int(counter) == 2:#also tried if counter ==2:
print('Hello World')
elif counter == 3:
print('Hello Jurassic World')
else:
print('This is the beginning')
Current output:
counter: 1
This is the beginning
counter: 2
This is the beginning
counter 3:
This is the beginning
Desired output:
counter: 1
This is the beginning
counter: 2
Hello World
counter: 3
Hello Jurassic World
I've tried printing type(counter), but that returns int.
Aucun commentaire:
Enregistrer un commentaire