dimanche 9 juillet 2017

When going through some if and elif clauses it just stops in one?

Hello I am doing a python homework. Now I'm in secondary and I'm pretty bad at python as I haven't been exposed to it for long. So I have a noobish question regarding the overall workings of python.

choice = input("Pick a letter that you think is in the word: ") 
if choice in right or choice in wrong or choice not in abc:
    print("Oops! This letter has already been guessed or it's not a letter at all!")
    return
elif choice == realone:
    one = choice
    right.append(choice)
elif choice == realtwo:
    two = choice
    right.append(choice)
elif choice == realthree:
    three = choice
    right.append(choice)
elif choice == realfour:
    four = choice
    right.append(choice)
elif choice == realfive:
    five = choice
    right.append(choice)
elif choice == realsix:
    six = choice
    right.append(choice)
else:
    guesses = guesses - 1
    wrong.append(choice)

So lemme explain it all. This is a part of my Hangman code. Choice is a character the player guesses. real(somenumber) variable is what the real letter of the word is. The numbers one two three without the real in front is for displaying that you got the character correct. However when a word gets picked that has characters that are repeated (adduct) it kind of fails. So when I type in d, it only displays one of the d's in adduct (the first one). I think it goes through the if elif clauses and when it falls into one it doesn't go further. Anyone got any suggestions? Explain if possible :)

Aucun commentaire:

Enregistrer un commentaire