Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- wordlist = ["ardvark", "baboon", "camel"]
- #todo #1 randomly choose word from list and assign it a variable
- #todo #2 ask user to guess a letter and assign it a variable
- #todo #3 check if letter is in the chosen word
- ########################
- #todo #4 create a empty list with the same amount of blanks as letters
- #todo #5 loop through each posiion of hangword and if the letter
- #matches chnage the blank with that letter
- #todo #6 print the blanks with the guessed letter
- #todo #7 use while loop to guess again
- endgame = False
- hangword = random.choice(wordlist)
- blankword = []
- for letter in hangword:
- blankword.append("_ ")
- while not endgame:
- print(blankword)
- userguess = input("Guess a letter ").lower()
- for position in range(len(hangword)):
- letter = hangword[position]
- if letter == userguess:
- print("Right!")
- blankword[position] = letter
- else:
- print("Wrong!")
- if "_ " not in blankword:
- endgame = True
- print("You Win!")
- #print("Congrats")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement