bionvector.blogg.se

Find jumble words
Find jumble words












Play = input("Do you want to play again? (yes or no)") You have the same last line in both branches of : if guess = word: Thus, if condition guess = word in the if branch is not true, we always go in the guess = "" part. In order for this condition not to be true, we must have : guess = word or guess = "". You have : while guess != word and guess != "":Īfter the loop, we know that condition guess != word and guess != "" is not true anymore (because we would have stayed in the loop otherwise). Print("The jumble is:", get_jumble_word(word))

FIND JUMBLE WORDS CODE

Now, the whole code is much simpler (also, you don't need word AND correct) : def get_jumble_word(word): The logic to create a jumble version looks like it could and should be put in a function on its own.Īlso we can reuse already existing functions : shuffle. ("answer", "You cant find it? the _ is _"), At the moment, I've decided to store this in a list of tuple (a dictionnary would also have done the trick). It would be much clearer to store the hint are the words together in a structure. Here you are comparing strings to get the relevant hint for an answer. Sometimes, you have to write a lot of code because "Hey, I have a lot of logic to write, I have to write code, that's the point of programming" but the point is more to keep things simple and to use the right tool (which is not always code) for the right thing. You do not respect PEP 8 and you should try to split your code into smaller chunks. Some comments from this question still apply here. Input("\n\nPress the enter key to exit.")

find jumble words

Play=input("Do you want to play again? (yes or no)") Print("Thanks for takeing the hint, idiot.") # create a variable to use later to see if the guess is correct # pick one word randomly from the sequence Play=input("Do you want to play? (yes or no)") (Press the enter key at the prompt to quit.)

find jumble words

WORDS = ("python", "jumble", "easy", "difficult", "answer", "xylophone") # create a sequence of words to choose from # The player has to guess the original word # The computer picks a random word and then "jumbles" it I want to know if there is anything simple I can do to shrink it and add a little spice to the code. This game that I semi coded is a little bulky and kind of boring.












Find jumble words