My_tup2 = tuple(str(i)) what is the 2nd tuple? My_tup = ( 'Entry%d' % i, ) Would the entry be the words or the letters in all the words? So using the example for the program aboveįor i in range in xrange (5): meaning I will have 5 chances. Print "Aww, thats too bad, the word is mine forever" Print "The word is", len(word), "letters long." WORDS = ("python", "jumble", "difficult", "answer", "xylophone", Print "Hello, I will give you 5 chances to guess letters of one of my secret words.\n On the final chance, you must guess the word" # Players pick letters in a random secret word TypeError: cannot concatenate 'str' and 'tuple' objects # Guess My Word If you better define how the user will interact (which in turn describes how your program must behave) you'll have a much better idea of where to go next with the program. How does the program tell them how many more letter guesses the player has?Ĭan the player make more than one guess at the word?ĭoes the game play more than once, or does it quit and the user has to re-start it to play again? How does the program tell them whether or not the letter is in the word? How does the user specifiy they are guessing a letter or if they are guessing the word? The message 'Lower Letter' which means the computer's word would appear before the word the player guessed in the dictionary and the message 'Higher Letter' which means the computer's word would appear after the word the player guessed are not very intuitive.īefore you go writing a bunch of code, plan how you think the user might interact with a program that worked like what you describe. You let them guess at the word and tell them if the word is what they guessed, or if it comes alphabetically before or after their guess. This program appears to be a merge of the 'have the computer pick a word and have the user guess it' and your 'number guessing' program.Īs written, the user doesn't have any interface to ask if the word contains a letter. Raw_input("\n\nPress the enter key to exit.") While (guess !=correct) and (guess !=""): Print "Guess the word hint there are :", len(word) # create a variable to use later to see if the guess is correct I am able to check the letters in the words higher or lower value,but how do I do it in a way that computer will check and respond back yes and no whether the letter is in the word plus I have to do it 5 tries before player must guess the word. Unfortunately I screwed up I got the random part and how many letters in the word. Computer responds yes and no after the 5 chances player must guess the word. Then the player gets 5 chances to ask whether letter is in the word. Computer tells the player how many letters are in the word. Original Exercise - Computer picks a random word from a list and player guesses the word. How do I modify this program player has 5 chances to ask a letter is in the word.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |