close

[Solved] AttributeError: ‘str’ object has no attribute ‘append’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error AttributeError: ‘str’ object has no attribute ‘append’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How AttributeError: ‘str’ object has no attribute ‘append’ Error Occurs?

Today I get the following error AttributeError: ‘str’ object has no attribute ‘append’ in python.

How To Solve AttributeError: ‘str’ object has no attribute ‘append’ Error ?

  1. How To Solve AttributeError: 'str' object has no attribute 'append' Error ?

    To Solve AttributeError: 'str' object has no attribute 'append' Error
    If you want to append a value to myList, use myList.append(s).
    Strings are immutable — you can't append to them.

  2. AttributeError: 'str' object has no attribute 'append'

    To Solve AttributeError: 'str' object has no attribute 'append' Error
    If you want to append a value to myList, use myList.append(s).
    Strings are immutable — you can't append to them.

Solution 1


If you want to append a value to myList, use myList.append(s).

Strings are immutable — you can’t append to them.

Solution 2

myList[1] is an element of myList and it’s type is string.

myList[1] is str, you can not append to it. myList is a list, you should have been appending to it.

>>> myList = [1, 'from form', [1,2]]
>>> myList[1]
'from form'
>>> myList[2]
[1, 2]
>>> myList[2].append('t')
>>> myList
[1, 'from form', [1, 2, 't']]
>>> myList[1].append('t')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'append'
>>> 

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read