This should fix it:
def print_guessed(secret_word):
return '-'*len(secret_word)
The problem with your code is that you are trying to modify a string by its index. However str
object in Python is not mutable. You have to construct a new string.
Note that this function returns the same result as other people have proposed. However it is much simpler (and may be faster) as it does not require looping.
2
solved Python simple code i cant fix help1!1