+ 1
Error in list function
Whats wrong with this code? words=("hey","you") words.insert(1, "yes") The idle brings an error message
2 Answers
+ 6
look, here 'words' is a tuple. Tuple types are iterable but they cannot be changed.
They are immutable type objects.
Do like below instead.
words =["hey", "you"]
words.insert(1, "yes")
new = tuple(words)
print(new)
0
Ooh, its a list, thanks