#Make word list of 20 words import random import urllib2 global guessCount guessCount = 0 global guessesRemaining guessesRemaining = 6 def readFile(): urlData = urllib2.urlopen("http://www.mieliestronk.com/corncob_lowercase.txt") urlData.read() urlData = urlData.split("\n") for line in urlData: print line def checkStart(): global guessCount isStart = input("Would you like to start?") #seems to skip over this line and immediately assume it's a no if(isStart == "Y"): scramble() else: print "Wow. You really love fun stuff don't you?" def guess(): guess = input("What is your guess for the word?") return guess def checkGuess(): global word global guessCount global guessesRemaining if(guess() == word): print print "Correct." playAgain() else: if(guessCount < 6): print print "Incorrect" guessesRemaining = guessesRemaining - 1 guessCount = guessCount + 1 guessesRemaining print "You have", guessesRemaining,"guesses remaining." checkGuess() else: print "Game Over" playAgain() def scramble(): global words words = ["water","guess","vacant","ignorant","fortress","station","flag","book","green","grass","flare"] random.shuffle(words) global word word = words[0] num_lets = range(len(word)) jumbled_word = "" random.shuffle(num_lets) for i in num_lets: jumbled_word = jumbled_word + word[i] print jumbled_word for i in num_lets: print "_", return jumbled_word def playAgain(): guessCount = 0 playAgain = input("Would you like to play again?(Y/N)") if(playAgain == "Y"): scramble() checkGuess() else: print "Goodbye" def game(): checkStart() checkGuess() readFile()
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