alright fellas, here is my approach to simulate a goto sequence: is there (and there usually is) a more eloquent way? PS: the idea with storing the variable in a class variable was just for fun (because of the .(format()) accessing story.
n=0
while n==0:
print("Whats your height?")
height=input()
print("Whats your age?")
age=input()
class loop:
h=height
a=age
print("Your height is {answer.h}".format(answer=loop()))
print("Would you like to continue?")
answer=input()
if answer=="yes":
++n
print("alright ONE MORE TIME!")
else:
print("see you")
Aucun commentaire:
Enregistrer un commentaire