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
- hangword = random.choice(wordlist)
- num_ = len(hangword)
- blankword = []
- for letter in hangword:
- blankword.append("_ ")
- #print(blankword)
- position = -1
- userguess = input("Guess a letter ").lower()
- for letter in hangword:
- position += 1
- print(position)
- if letter == userguess:
- blankword[position] = userguess
- print("Right")
- else:
- print("wrong")
- print(blankword)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement