AttributeError: 'unicode' object has no attribute 'append'


#1


hobbies = [0]
for hobbies in range (3):
hobbies = raw_input("Please enter one of your hobbies: ")
hobbies.append(hobby)
print "Updated List : ", hobbies


Please enter one of your hobbies: jj
Please enter one of your hobbies: ee
Please enter one of your hobbies: hh

Traceback (most recent call last):
File "python", line 6, in
AttributeError: 'unicode' object has no attribute 'append'

to work


Replace this line with your code.


#2

your loop iterator (hobbies) and the variable where you store the result of the prompt and your list all have the same name, this will garantued overwrite certain variable. don't use the same variable names


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.