[Solved] Project hangman! Logic Error. Project description is given. Only suggest logical correction in implementation. | SoloLearn: Learn to code for FREE!

0

# [Solved] Project hangman! Logic Error. Project description is given. Only suggest logical correction in implementation.

A player has exactly 8 tries and enters letters. If a player has more tries but he actually guessed the word, it doesn't mean anything. If the letter doesn't occur in the word, the computer takes one try away, even if the user already inputted this letter before. If the player doesn't have any more attempts, the game should end and the program should show a losing message. Otherwise, the player can continue to input letters. Also, use our previous word list: 'python', 'java', 'kotlin', 'javascript' so that your program can be tested more reliably. https://code.sololearn.com/c5CJZeKW4Ic3/?ref=app

7/2/2020 8:50:18 AM

Subham

+1

Hopefully the "nice" view amount doesn't get ruined by me

0

Now how do I reduce try for repeated letters?

0

guessing word java j entered twice is one turn missed

0

second j decrements turns by 1

0

import random guess_word = random.choice(['python', 'java', 'kotlin', 'javascript']) lost = "Thanks for playing!\nWe'll see how well you did in the next stage" msg = [lost, 'You survived!'] print('H A N G M A N') def hangman(word, msg): turns = 8 guessmade = "" invalid_letter="" while len(word) > 0: main = "" for letter in word: if letter in guessmade: main = main + letter invalid_letter += letter else: main = main + "_" + " " if main == word: print(main) print("Thanks for playing!") break print(main+"\n") guess = input("Input a letter:") if guess in word: guessmade = guessmade + guess elif guess not in word: turns -= 1 print("No such letter in the word") if turns == 0: print(msg[0]) break if guess in invalid_letter:

0

Wrong answer in test #1 Last block should not contain text "Input a letter"

0

H A N G M A N _ _ _ _ _ _ Input a letter: _ _ _ _ _ _ Input a letter: _ _ _ _ _ _ Input a letter: _ _ _ _ _ _ Input a letter: _ _ _ _ _ _ Input a letter: _ _ _ _ _ _ Input a letter: _ _ _ _ _ _ Input a letter: _ _ _ _ _ _ Input a letter: _ _ _ _ _ _ Input a letter:k No such letter in the word _ _ _ _ _ _ Input a letter:o _ _ _ _ o_ Input a letter:p p_ _ _ o_ Input a letter:y py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_ Input a letter: py_ _ o_

0

import random guess_word = random.choice(['python', 'java', 'kotlin', 'javascript']) lost = "Thanks for playing!\nWe'll see how well you did in the next stage" msg = [lost, 'You survived!'] print('H A N G M A N') def hangman(word, msg): turns = 8 guessmade = "" invalid_letter="" while turns > 0: main = "" for letter in word: if letter in guessmade: main = main + letter invalid_letter += letter else: main = main + "_" + " " if main == word: print(main) print("Thanks for playing!") break print(main+"\n") guess = input("Input a letter:") if guess in word: guessmade = guessmade + guess elif guess not in word: print("No such letter in the word") turns -= 1 if turns == 0: print(msg[0]) break if guess in invalid_letter:

0

Not yet

0

Cannot parse this block - it contains spaces in the first line, but shouldn't

0

Wrong answer in test #1 Last block should not contain text "Input a letter" Please find below the output of your program during this failed test. is what I get for your code

0

def hangman(word, msg): turns = 8 guessmade = "" invalid_letter="" while turns > 0: main = "" for letter in word: if letter in guessmade: main = main + letter invalid_letter += letter else: main = main + "_" + " " if main == word: print(main) print("Thanks for playing!") break print(main+"\n") guess = input("Input a letter:") if guess in word: guessmade = guessmade + guess elif guess not in word: print("No such letter in the word") turns -= 1 if turns == 0: print(msg[0]) break if guess in invalid_letter: turns -= 1 hangman(guess_word , msg) is my version and the error is Last block should contain text "Thanks for playing!"

0

https://hyperskill.org/projects/69/stages/376/implement#solutions

0

def hangman(word, msg): turns = 8 guessmade = "" invalid_letter="" while turns > 0: main = "" for letter in word: if letter in guessmade: main = main + letter invalid_letter += letter else: main = main + "_" + " " if main == word: print(main) print("Thanks for playing!") break print(main+"\n") guess = input("Input a letter:") if guess in word: guessmade = guessmade + guess elif guess not in word: print("No such letter in the word") turns -= 1 if guess in invalid_letter: turns -= 1 print(msg[0]) hangman(guess_word , msg) this is constantly getting error Cannot parse this block - it contains spaces in the first line, but shouldn't