okay, so how do I go about making sure it chooses the the right word from the answer list? and I having another issue when the wrong word is entered I want it to ask again until the user gets it correct. This game is called “Unscramble the Word”, where the player would be presented a 7-letter word that has been scrambled and would have to provide the unscrambled word as the correct answer to gain a point. A wrong answer would end the game. This games uses only the very basic of Python functions. For example, choosing a random 7-letter word from a list, changing the sequence of the letters (i.e. string manipulation), and then using an if-else statement to award the point for the correct answer. The game also uses a for loop to allow the player to play up to 5 rounds. Let us consider the block of code below. The code shown would not start from Line 1 or have continuous Line numbering as with previous post, as some comments/notes present in the code has been omitted for simplicity sake. Given some data in a text file, the task is to scramble the text and output in a separate text file. So, we need to write a Python program that reads a text file, scrambles the words in the file and writes the output to a new text file. Rules to be followed:
On executing the program, it should prompt the user to enter input file name and generate an output file with scrambled text. The output file should be named by appending the word “Scrambled” to the input file name. Example: Input : MyFile.txt -> Scrambling words is very interesting. Because even if they are scrambled, it doesn't impact our reading. Because we don't read letter by letter, we read the word as a whole. Output : MyFileScrambled.txt -> Srbmnacilg words is very itrensientg. Bscauee even if tehy are srelabcmd, it dosn'et ipcmat our raidneg. Bacusee we dn'ot raed lteetr by letetr, we raed the word as a wolhe. Below is the implementation : Python3
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.0 , Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.2 , Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.4 , Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.6 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.7 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.8 = import 0
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.7
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.08
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.10
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.12
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.18
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.21 "." 0
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.53 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.54 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.53 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.56
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.59 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.60 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.61
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.21 "." 0
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.53 6Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.53 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.56
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.76
Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.80 "." 1Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.82 "." 3Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.53 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.85 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.86 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.87 Smcinrablg wodrs very Bauscee eevn tehy dnoes't icpamt Bcuesae d'not read lteter raed wrod whole.88 |