import random
word_list = ['ardvark', 'baboon', 'camel']
word = random.choice(word_list)
riddle = len(word) * '_'
print(riddle)
while '_' in riddle:
guess = input('Guess a letter: ').lower()
for letter in word:
index = (word.index(guess))
if letter == guess:
riddle[index] = letter
print(riddle)
resulting in
riddle[index] = letter
TypeError: 'str' object does not support item assignment
I know I know, strings are immutable but still... why? They are indexable so this just might work somehow if proper workaround is applied. Or not?