I’m making a simple program, but after inputting, there is always a ‘ValueError: invalid literal for int() with base 10’ after I try to put in a word. Basically, this program is supposed to make you type in a 3 letter word, but whenever I try and put in a word, there’s only an error message.
words = []
game = "play"
while game == "play":
new = input("write something with 3 letters: ")
if len(new) > 3 or len(new) < 3:
print("That's not a 3 letter word.")
else:
if new in words:
game = "over"
print("you already said that word. Game over.")
print("You know len(words), 3 letter words.")
else:
print("u win")
words.append(new)
did I do anything wrong? the problem seems to be in line 4???
>Solution :
I think I know whats going wrong 🙂
words = []
game = "play"
while game == "play":
new = input("write something with 3 letters: ")
if len(new) > 3 or len(new) < 3:
print("That's not a 3 letter word.")
else:
if new in words:
game = "over"
print("you already said that word. Game over.")
print("You know len(words), 3 letter words.")
else: # <---- you forgot a few tabs here ;)
print("u win")
words.append(new) # <---- this part is important
you never appended the new words to the list.