Improve "Word Jumble" so that each word is paired with a hint. The player should be able to see the hint if he or she is stuck. Add a scoring system that rewards players who solve a jumble without asking for the hint.
Can anyone show me where i've gone wrong?
# Word Jumble
#
# The computer picks a random word and then "jumbles" it
# The player has to guess the original word
#
# Michael Dawson - 1/28/03
import random
# create a sequence of words to choose from
WORDS = ("python", "jumble", "easy", "difficult", "answer")
# pick one word randomly from the sequence
word = random.choice(WORDS)
#adding a scoring system
score = 100
# create a variable to use later to see if the guess is correct
correct = word
# create a jumbled version of the word
jumble =""
#adding scoring to hint:
hint = 0
while word:
position = random.randrange(len(word))
jumble += word[position]
word = word[:position] + word[(position + 1):]
# start the game
print \
"""
Welcome to Word Jumble!
Unscramble the letters to make a word.
(Press the enter key at the prompt to quit.)
"""
print "The jumble is:", jumble
guess = raw_input("\nYour guess: ")
guess = guess.lower()
while (guess != correct) and (guess != ""):
guess = raw_input("Your guess: ")
guess = guess.lower()
if guess == "hint" and word == "python":
print "it's a programming language"
score -=10
hint += 1
elif guess =="hint" and word == "jumble":
print "It's what your playing now"
score -=10
hint += 1
elif guess =="hint" and word =="easy":
print "Opposite of hard is..."
score -=10
hint += 1
elif guess =="hint" and word =="difficult":
print "this word jumble is pretty d...."
score -=10
hint += 1
elif guess =="hint" and word =="answer":
print "the a....r"
score -=10
hint += 1
elif guess == correct:
score +=20
print "thats it! You guessed it!\n"
print "You got ", score, "points"
if score == 100 and hint == 0:
score +=100
print "\nYou got an extra 100 points for not having any hints!"
break
print "Thanks for playing."
raw_input("\n\nPress the enter key to exit.")
Also having troubles with this:
The challange is to:
Create a game where the computer picks a random word and the player has to guess that word. The computer tells the player how many letters are in the word. Then the player gets five chances to ask if a letter is in the word. The computer can only respond with "yes" or "no". Then, the player must guess the word.
I've had a go and it keeps having problems, like it'll say the word is correct even though it's not correct, which is very weird.
Any tips?
#computer guessing word program
#lamine haddadi
import random
WORDS =("bottle", "screen", "controller", "guitar")
chance = 1
count = 0
random = random.choice (WORDS)
print "There are ", len(random), "letters in the word"
print random
raw_input("Press enter to continue...")
print "\n\nYou have five chances to guess which letter are in the word"
letters = raw_input("what letter do you guess? ")
for i in range(4):
if letters in random:
print "yes"
letters = raw_input("what letter do you guess?")
else:
print "no"
letters = raw_input("what letter do you guess?")
print "Time to have a guess..."
guess = raw_input("What is the word? ")
if guess == random:
print "Well done thats correct"
else:
print "thats incorrect, try again"
guess = raw_input("\nWhat is the word? ")
print "Well done thats correct"
raw_input("Press enter to continue...")
Thanks
thank you.
Edited by synk, 15 February 2011 - 11:09 AM.


Sign In
Create Account


Back to top









