I am creating a hangman game for my GCSE Computing Project. I have come across an error that I cannot seem to rectify.
This is all of the code:
import random
#Creates a tuple with words in
WORDS = ("church","smelly","chicks")
#This picks a word randomly
word = random.choice(WORDS)
print("The word is", len(word), "letters long.")
#This is the game
for i in range(1):
letter1 = input ("Guess a letter:")
if letter1 in word:
print("Correct. This letter is in the word")
else:
print("Incorrect. This letter is not in the word.")
for i in range(1):
letter2 = input ("Guess a letter:")
if letter2 in word:
print("Correct. This letter is in the word")
else:
print("Incorrect. This letter is not in the word.")
for i in range(1):
letter3 = input ("Guess a letter:")
if letter3 in word:
print("Correct. This letter is in the word")
else:
print("Incorrect. This letter is not in the word.")
for i in range(1):
letter4 = input ("Guess a letter:")
if letter4 in word:
print("Correct. This letter is in the word")
else:
print("Incorrect. This letter is not in the word.")
for i in range(1):
letter5 = input ("Guess a letter:")
if letter5 in word:
print("Correct. This letter is in the word")
else:
print("Incorrect. This letter is not in the word.")
for i in range(1):
letter6 = input ("Guess a letter:")
if letter6 in word:
print("Correct. This letter is in the word")
else:
print("Incorrect. This letter is not in the word.")
all_letters = [letter1, letter2, letter3, letter4, letter5, letter6]
# Conditions for winning/losing
if all_letters in word:
print("Well done, you got it.")
else:
print("Sorry, You are the loser.")
When I run the program, I get this error
TypeError: 'in <string>' requires string as left operand, not list
I am not sure how to fix this error, can someone please help me?
Also, if you're able to, can you give me some advice on what to improve any section of the whole code.
*This is my first question, forgive me if I've been a bit extensive"
for i in range(1)?i=0.