Well, I know that you can run the program as long as a certain condition is true using the while statement . However, is it wrong or bad practice to just call a function in else , as shown below?
def ask():
me = input("What is your name? ")
if me == "Tom":
print("Hi, Tom!")
else:
print ("Who are you?")
ask()
This seems like a lighter, shorter version of the “while statement”, but in fact I have not seen a program like this in Python tutorials.
jerry source
share