I started this hangman game as a suggestion for beginners but now I am stuck. The code runs with out any errors but I need some way to put a certain amount of turns that the user can have but I am not sure how I could add this to my loop? I know I would first create something like turns = 10. Right now all my code does is ask if you want to play then once you answer it shows the letters the word has then exits.So I need some help to get it to continue untill the word was guessed correct or the turns are up.
#!/usr/bin/env python import random words = ['sprinkles', 'computer', 'mouse', 'shooter', 'edge', 'guard', 'python'] myword = random.choice(words) guesses = "aeiou" while play: print "Do you want to play a game?" play = raw_input('Answer (y) yes or (n) no:') if play == 'y': print 'Let\'s begin' print "" for letter in random.choice(words): if letter in guesses: print letter, else: print '_', break if play == 'n': print 'Good-Bye.'