Python Forum
Cant Append a word in a line to a list err "str obj has no attribute append - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/Forum-Python-Coding)
+--- Forum: General Coding Help (https://python-forum.io/Forum-General-Coding-Help)
+--- Thread: Cant Append a word in a line to a list err "str obj has no attribute append (/Thread-Cant-Append-a-word-in-a-line-to-a-list-err-str-obj-has-no-attribute-append)



Cant Append a word in a line to a list err "str obj has no attribute append - Sutsro - Apr-22-2020

Hey everyone,

I am trying to get every word in line to a list however i am getting error " AttributeError: 'str' object has no attribute 'append'". Any ideas are welcome, thanks in advance.

if satırsayısı2==isimsatırlistesi[0]:
        for word in line2:
            word.append(str(adressatırı)) #[b]AttributeError: 'str' object has no attribute 'append'[/b]
            satırdakikelimesayısı=len(adressatırı)
            print(adressatırı[2:satırdakikelimesayısı])



RE: Cant Append a word in a line to a list err "str obj has no attribute append - anbu23 - Apr-22-2020

wrd=[]
if satırsayısı2==isimsatırlistesi[0]:
        for word in line2:
            wrd.append(str(adressatırı)) 
            satırdakikelimesayısı=len(adressatırı)
            print(adressatırı[2:satırdakikelimesayısı])
entireLine=",".join(wrd)



RE: Cant Append a word in a line to a list err "str obj has no attribute append - deanhystad - Apr-22-2020

You have not supplied enough information. What is line2? What is adressatiri? What are your trying to do with this:
word.append(str(adressatırı))