Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import choice
- word_list=["alien", "sponge", "bar", "night", "valkyrie", "water", "gentle", "python", "boring", "hand", "cereal", "word", "sad", "minecraft", "lamb", "turkey", "fire", "whelp", "dwarves", "cyan", "skyrim", "pie", "cake", "portal", "life", "death", "ogre", "mister"]
- selected_word=choice(word_list)
- characters=len(selected_word)
- length=characters
- num=characters-1
- word=list(selected_word)
- guessed_word_string="-"*characters
- guessed_word=list(guessed_word_string)
- print "Note that this is only a test, and therefore, there are only a few words in the game."
- win=False
- lose=False
- tries=input("How many tries do you want? (Standard is 10, maximum is 50) Please remember to use numbers instead of words, for the latter will crash the game: ")
- if tries>50:
- while tries>50:
- print "Oops, you did something wrong. Please do not excede the maximum number of tries in your selection."
- tries=input("Go ahead, try again: ")
- print "The word is", characters, "letters long."
- print "You have", tries, "tries left."
- game="running"
- while game=="running":
- if win==True:
- print "Congratulations! you guessed the word!"
- game="finished"
- elif lose==True:
- print "Oh, bummer... You lose. :( Maybe you want to try again?"
- game="finished"
- else:
- while win==lose:
- if word==guessed_word:
- win=True
- elif tries==0:
- lose=True
- else:
- if win==True:
- print "Congratulations! you guessed the word!"
- elif lose==True:
- print "Oh, bummer... You lose. :( Maybe you want to try again?"
- else:
- print guessed_word_string
- answer=raw_input("Choose a letter to guess: ")
- while len(answer)!=1:
- answer=raw_input("You must select a single letter: ")
- if answer in word:
- while answer!=word[num]:
- num-=1
- if guessed_word[num]==answer:
- print "Silly! You already selected that letter!"
- else:
- guessed_word[num]=answer
- num=characters-1
- guessed_word_string=""
- while length>0:
- length-=1
- guessed_word_string=guessed_word[length]+guessed_word_string
- length=characters
- print "Correct!"
- else:
- print "Nope, try again!"
- tries-=1
- print "You have", tries, "tries left."
Add Comment
Please, Sign In to add comment