String object has no attribute "append"

Matt Graves tunacubes at gmail.com
Tue May 28 14:25:30 EDT 2013


I receive this error while toying around with Functions...

def pulldata(speclist,speccolumn):
    with open('profiles.csv', 'r') as f:
              reader = csv.reader(f)
              for column in reader:
                 (speclist).append(column[('speccolumn')])

pulldata(speclist = 'numbers', speccolumn = "0")


>Traceback (most recent call last):
>  File "C:\Desktop\Python\CFI\Devices V2\users.py", line 17, in <module>
>    pulldata(speclist = 'numbers', speccolumn = "0")
>  File "C:\Desktop\Python\CFI\Devices V2\users.py", line 16, in pulldata
>    (speclist).append(column[('speccolumn')])
>AttributeError: 'str' object has no attribute 'append'

I'm getting the error because it should say "numbers.append", but it is reading it as "(speclist).append".

This is my first time playing with functions, so be gentle. 



More information about the Python-list mailing list