#Simple Hangman import random # Creates a tuple with words in WORDS = ("buttercup", "triangle", "butterfly", "miasma", "rectangle", "science") #Pick a word randomly word = random.choice(WORDS) print("The word is", len(word), "Letters long.") for i in range(5): letter = input("Guess a letter: ") if letter in word: print("Yes, the word contains:", letter) else: print("No, it doesn't contain: ", letter) print("That's all your letters guesses used up.") guess = input("Now guess the word: ") if guess == word: print("Well done, you got it!") else: print("Sorry, Wrong.")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question