mardi 27 janvier 2015

Having difficulty with breaking a while loop in Python 3.x


win = False
check_for_words = ["JOKE","EYEBROWS","VELLUM"]
words = ["JOKE","EYEBROWS","VELLUM"]

def play_game(words):
for i in range(len(words)):
print(words[i])
if sorted(words) == sorted(check_for_words):
win = True
print("Well done you won!")
exit()
while win == False:
pairing_menu()


play_game(words)


I am having a problem with stopping the game and exiting it. I am not getting any errors as such, but the game isn't running as planned, the game continues running. I have not submitted all my source code, as I am worried this will make looking through the code more difficult for those answering.


What I am not understanding is that I have a specific if statement which then changes 'win = False' to 'win = True', even though I have changed the 'win' variable to 'True', the game proceeds as normal.


All answers greatly appreciated!


Aucun commentaire:

Enregistrer un commentaire