小编ano*_*ous的帖子

Python AttributeError:“ dict”对象没有属性“ append”

我正在创建一个循环,以便将来自用户输入的值连续追加到字典中,但出现此错误:

AttributeError: 'dict' object has no attribute 'append'
Run Code Online (Sandbox Code Playgroud)

到目前为止,这是我的代码:

    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]
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

python dictionary for-loop tuples

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

dictionary ×1

for-loop ×1

python ×1

tuples ×1