Oct-11-2024, 07:54 PM
hello
i struggle hard with this project.
the gamer needs to guess a word and i have figured everything out bur i want to give the gamer some help.
when he guesses and writes a whole word and it has some of the same letters as the word to guess the letters that are the same are printet in the spot as the gamer puts them in but in .lower(). if the leter is alo in the right spot as the word to figure out the letter will be .upper().
example
secret word: flower
gamers guess: gloppte
hint: _L O _ _ e
again gamer
guess: ffffff
hint: F f f f f f
and so on until he is right
thank you all so much
i struggle hard with this project.
the gamer needs to guess a word and i have figured everything out bur i want to give the gamer some help.
when he guesses and writes a whole word and it has some of the same letters as the word to guess the letters that are the same are printet in the spot as the gamer puts them in but in .lower(). if the leter is alo in the right spot as the word to figure out the letter will be .upper().
example
secret word: flower
gamers guess: gloppte
hint: _L O _ _ e
again gamer
guess: ffffff
hint: F f f f f f
and so on until he is right
hidden_word = 'flower' #random.choice(random_words) comes later guess ='' guess_count = 0 hint = '_ ' * len(hidden_word) print('Welcome to the word guessing game!') print() while guess != hidden_word: print(f'Your hint is: {hint}') guess = input('What is your guess? ').lower() # counts the guesses guess_count = guess_count + 1 # this controls the lenghs of the guess if len(guess) > len(hidden_word): print('Sorry, the guess must have the same number of letters as the secret word.') elif len(guess) < len(hidden_word): print('Sorry, the guess must have the same number of letters as the secret word.') #does not work for char in hidden_word: if char.lower() in guess: print(char.upper, end='') else: print('_', end='') #an other try to make it work but doesn t work either for letter in hidden_word:None if letter.lower() == guess.lower(): print(letter.upper(), end='') else: print(letter.lower(), end='') else: print('Congratulation! you guess it! ') print(f'It took you {guess_count} guesses. ') print()does anyone of you have some ideas
thank you all so much