I'm writing a hangman code, and am having trouble with setting an error for an invalid letter guess (ie. the guess should be between a-z, no numbers or multiple letter strings). This may be a fairly simple solution, but I am having trouble formalizing the code. Here is how I implemented the code:
while ((count < 6) and win):
guess = input("Please enter the letter you guess: ")
if guess:
try:
guess = guess.lower()
lettersCorrect += 1
if (guess not in letterList): #SYNTAX ERROR
print ("You need to input a single alphabetic character!")
continue
I noted where I am getting the syntax error. letterList is a list I created containing all acceptable letters (a-z). Is my coding off, or is there an easier way to say, "if not in letterList".
Thanks.