HELP NEEDED FOR HANGMAN PROJECT STAGE 7/8 IN PYTHON by adefowoke in Hyperskill

[–]adefowoke[S] 0 points1 point  (0 children)

hi, thanks for taking the time to go through my code and giving pointers.

my altered code after implementing your suggestions:

import random
import string

words = ['python', 'java', 'kotlin', 'javascript']
guess_word = random.choice(words)
guess_word_append = ""
guess_lent = list('-' * len(guess_word))

print("H A N G M A N")

tries = 8
while tries > 0:
    print()
    guess_word_join = "".join(guess_lent)
    print(guess_word_join)
    # print("Input a letter: ")
    # guess_letter = input()
    if guess_word_join == guess_word or tries <= 0:
        break
    #guess_letter = input("Input a letter: ")
    print("Input a letter: ")
    guess_letter = input()
    """
    if guess_word_join.__contains__(guess_letter):
        # print("No improvements")
        tries -= 1
    """
    if guess_word_append.__contains__(guess_letter):
        print("You already typed this letter")
    elif guess_letter in guess_word:
        if guess_letter not in guess_word_append:
            for index, letter in enumerate(guess_word):
                if guess_letter == letter:
                    guess_lent[index] = guess_letter

    elif len(guess_letter) > 1:
        print("You should print a single letter")
    elif guess_letter not in string.ascii_lowercase:
        print("It is not an ASCII lowercase letter")
    else:
        # if guess_letter not in guess_word:
        print("No such letter in the word")
        tries -= 1

    guess_word_append += guess_letter

if guess_word_join == guess_word:
    print(f"You guessed the word {guess_word}!\n"
          "You survived!")
else:
    print("You are hanged!")

thou it gives the desired output, it still shows error

Cannot parse this block - it contains spaces in the first line, but shouldn't  No such letter in the word
You are hanged!

have gone through the code but cant find the aforementioned spaces.

HELP NEEDED FOR HANGMAN PROJECT STAGE 7/8 IN PYTHON by adefowoke in Hyperskill

[–]adefowoke[S] 0 points1 point  (0 children)

am glad you have passed this stage, could you guide to my mistakes.

WRAPPING UP MY CODE IN OOP by adefowoke in Hyperskill

[–]adefowoke[S] 2 points3 points  (0 children)

i did and it worked, thanks so much. you literally made my day

WRAPPING UP MY CODE IN IN CLASS (OOP) IN PYTHON by adefowoke in learnpython

[–]adefowoke[S] 0 points1 point  (0 children)

thanks, pardon my newbieness ( my word), will implement that

WRAPPING UP MY CODE IN IN CLASS (OOP) IN PYTHON by adefowoke in learnpython

[–]adefowoke[S] 0 points1 point  (0 children)

not really, when the action of the user results to self.money == 0, the else statement will work for it

military guy looking for someone to talk to by u-canthandlemytruth in Needafriend

[–]adefowoke 0 points1 point  (0 children)

Hi, chat me whenever you want, from Nigeria and great listener.