Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Put in a variable for your secret word
- word =
- # Creates a variable with an empty value
- guesses = ''
- # The number of turns
- turns = 10
- #check if the turns are more than zero
- while turns > 0:
- # make a counter that starts with zero
- failed = 0
- # Create a loop for every character in the secret word.
- # see if the character is in the players guess
- if char in guesses:
- # print out the character
- else:
- # if not found, print a dash
- # and increase the failed counter with one
- failed += 1
- # if failed is equal to zero
- # print You Won
- if failed == 0:
- print ("You won")
- # exit the script
- break
- # ask the user to guess a character
- guess = input(" guess a character:")
- # set the players guess to guesses
- guesses += guess
- # if the guess is not found in the secret word
- if guess not in word:
- # turns counter decreases with 1 (now 9)
- turns -= 1
- # print wrong
- print("Wrong")
- # how many turns are left
- print("You have", + turns, 'more guesses')
- # if the turns are equal to zero
- if turns == 0:
- # print "You Lose"
- print("You Lose")
Add Comment
Please, Sign In to add comment