I am creating a loop in order to append continuously values from user input to a dictionary but i am getting this error:
AttributeError: 'dict' object has no attribute 'append'
This is my code so far:
for index, elem in enumerate(main_feeds):
print(index,":",elem)
temp_list = index,":",elem
li = {}
print_user_areas(li)
while True:
n = (input('\nGive number: '))
if n == "":
break
else:
if n.isdigit():
n=int(n)
print('\n')
print (main_feeds[n])
temp = main_feeds[n]
for item in user:
user['areas'].append[temp]
Any ideas?
user['areas'] = temp
. Your code would only work IFuser[areas]
was already a list. If you need it to be a list, construct the list first, THEN assign that list to the key. – Polymerism