I need help with this code, I get an error message that says
File "<tmp 6>", line 4, in <module>
n.append(names)
AttributeError: 'str' object has no attribute 'append'
Code:
names = ['','','','','']
for i in range(1,6):
n = input("Enter a name: ")
n.append(names)
print (names)
nto the listnames, i. e.names.appned(n); but you did the opposite. Plus, if you want to get 5 names from user, you shouldn't initialize your list; you just define an empty list like this:names = []. Otherwise you'll have a list containing 5 empty strings and 5 other strings obtained from user.