Question: In python Here is the code. import random import os lst=[] def shuffled(word): shuffled_word = ''.join(random.sample(word, len(word))) return shuffled_word def select_category(): lst.clear() menu=Select a category
In python
Here is the code.
import random import os lst=[]
def shuffled(word): shuffled_word = ''.join(random.sample(word, len(word))) return shuffled_word
def select_category(): lst.clear() menu="Select a category of words to guess!. 1. colors 2. animals 3. fruits 4. flowers 5. soccer "
print(menu,end="") ch=int(input()) if ch==1: file='colors.txt' elif ch==2: file='animals.txt' elif ch==3: file='fruits.txt' elif ch==4: file='flowers.txt' elif ch==5: file='soccer.txt' else: print("Wrong choice!!") f=open(file,'r') for word in f: lst.append(word.strip())
def category(): word=random.choice(lst) shuffle_Word=shuffled(word) while True: print("Guess the word:",shuffle_Word,end="") guess_word=input() if guess_word==word: print("Correct!") break
else: print("Try again!") def main(): select_category() category() while True: print(" 1.Give me another word 2.Give me another category 3.Get me out of here!") choice=int(input()) if choice==1: category()
elif choice==2: select_category() category()
## elif choice==3: else: print("Wrong choice!") main()
Directions.
![In python Here is the code. import random import os lst=[] def](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f45297db81a_95966f452975c8d0.jpg)
csecure l https://miamioh.instructure.com/courses/53369/assignments/529621 WebEx Conferences Revise and convert your Jumblewords game to a class (if you do not like your solution, you can use mine) The requirements are: class WordJumbleGame: will contain all functionality to play the game. def-init--(self): Set up all of the category lists, so that you only read the files once. Create a variable to store the overall number of words guessed during the game (for example, self.wordsGuessed) and the number of words abandoned (self.wordsAbandoned). Dashboard Courses def jumbleword(self, word): Groups This stays the same although will need the self parameter added def play (self): Calendar This will contain all of the code needed to play the game Add functionality to let the user abandon a word that they cannot guess and select another. Inbox Track the total number of words that were guessed or abandoned. Help using your class def main0: game WordJumbleGame0 game.play0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
