现在,我知道已经对该主题进行了一些介绍,但我听不懂。我将向您展示我的代码,希望这可以帮助您了解我的位置。
字典
father = {"Yin": ["yang","yaha"]}
此代码可以正常工作。
elif choice == "5":
son = input("Enter the name of a son to get the name of his grandfather: ")
if son in father:
description = father[son]
print("\n", son, "'s grandfather is", description[1])
else:
print("\nSorry, I don't know who that is", son)
这段代码没有,我只是希望它能够更改列表中的第二项(yaha)。
elif choice == "6":
son = input("which grandfather and son pair need updating: ")
if son in father:
description = input("What's name of the grandfather?: ")
son[father] = description[1]
print("\n", son, "has been redefined.")
else:
print("\nThat person doesn't exist! Try adding it.")
任何帮助,将不胜感激。
开心每一天1111
慕码人8056858
相关分类