elif choice == "2":
print("These are terms stored in the dictionary so far: ")
for i in values_so_far:
print(i)
term = input("\nWhat term do you want me to add?: ")
if term not in Dictionary:
definition = input("\nWhat's the definition?: ")
Dictionary[term] = definition
print("\n",term,"has been added")
Dictionary.append[term]
values_so_far.append[term]
else:
print("\nThat term already exists! Try redefining it [option: 3]")
产生错误信息:
追溯(最近的呼叫最后):
文件“C:\ Users \ Flynn \ Desktop \ programs \ Programming Dictionary.py”,第98行,中
Dictionary.append [长期]
AttributeError:'dict'对象没有属性'append'
答案 0 :(得分:0)
行Dictionary[term] = definition
已添加了将term
和definition
关联到词典的键值对。 append
不是为字典定义的方法。
更多关于字典:
Python 2:https://docs.python.org/2/tutorial/datastructures.html#dictionaries
Python 3:https://docs.python.org/3/tutorial/datastructures.html#dictionaries