有人能帮忙吗?我需要让这个工作,但它不会,我已经适当地做了一个简单的错误,但我不能发现它。(忽略拼写错误)
countries = ["Spain","England","Scotland","USA","Wales","Ireland","France",
"Greece","China","Japan"]
print("1. Add a new country")
print("2. Delete a country")
print("3. Sort the countries")
choice = int(input("Select the option you require"))
if choice == 1:
newcount = input("Enter a country to be added to the list:")
countries.append(newcount)
print("Your countires are now:",countries)
if choice == 2:
deletec = input("Enter a country to be deleted:")
countries.pop(deletec)
print("Your countires are now",countries)
if choice == 3:
countries.sort
print("Your countries are now",countries)
pop
不像你想象的那样工作。改用remove
。你知道吗你忘了括号在
countries.sort()
相关问题 更多 >
编程相关推荐