I'm a beginner in coding but extremely motivated and determined to learn. I was writing mini programs in Python 3 to play around with my understanding for if, and break statements. In the program I have written below, even when I put my answer as Yes it still prints I'm sorry, I must've misheard you sir, my apologies. On top of that, when I add break to the end of the else, it tells me it's out of the loop. I want to add break so if I do say No the program can stop. Can someone please explain ?
name = str(input('What is your name? '))
wrongname = input('Are you really ' + name + '?')
if wrongname != 'Yes':
print("I'm sorry, I must've misheard you sir, my apologies")
else:
print('I heard all about you Mr. ' + name + '!')
input('What are you doing in town?')
input('Ah I see, well, I hope you enjoy your stay !')
print('Thank you !')
Aucun commentaire:
Enregistrer un commentaire