Reputation: 37
I am creating a hangman game and when I run my program the if statement doesn't get called even if it is correct. I have changed my .lower to .lower() but the if statement is still not ran.
theWord = list(possibleWords[0])
theWord = (' ').join(theWord)
#graphics
```````````````````````````````````````
def graphics():
graphic = []
graphic.extend(theWord)
for i in range(len(theWord)):
graphic[i] = ("_")
graphic = (' ').join(graphic)
print (graphic)
`````````````````````````````````````````````
#input
````````````````````````````````````````````````````````````````````````
def inputs():
count = (0)
while len(theWord) > (count):
for i in range(len(theWord)):
print (count)
guess = input("Guess a letter:").lower()
`````````````````````````````````````````````````````````````````````````
#right or wrong
```````````````````````````````````````````````````````````````````````````
if (guess) == theWord[i]:
graphic[i] = (guess)
print (graphic)
count = count + (1)
inputs()
Upvotes: 1
Views: 65
Reputation: 13106
Change guess
to input("Guess a letter:").lower()
. lower
with no parens is a function and will fail the equivalency check to a string:
somestr = 'HI'.lower
somestr
<built-in method lower of str object at 0x10e662f80>
somestr=='hi'
False
somestr = 'HI'.lower()
somestr=='hi'
True
Upvotes: 2