-1
代碼:爲什麼我在這段代碼中得到無效的語法錯誤,Python?
students = []
choice = None
while choice != 0:
print(
"""
0 - Exit
1 - Show all students
2 - Add a student
"""
)
choice = input("Choice: ")
print()
if choice == "0":
print("Goodbye")
break
elif choice == "1":
print("\nStudents: ")
for entry in students:
email, name, number = entry
print(name, "\t", email, "\t", number)
elif choice == "2":
name = input("What is the students name?")
email = input("What is the students email adress? ")
number = int(input("What is the students number? ")
entry = email, name, number
students.append(info)
students.sort(reverse=False)
student = students
else:
print("Sorry, but", choice, "isn't a valid choice.")
當我在編譯器中運行它,我得到一個語法錯誤行
entry = email, name, number
我不知道爲什麼,請告訴我。
請記住,報告的行是錯誤被檢測到的行,它不一定是包含錯誤的行。這是因爲換行在'()'內是有效的,所以如果你有一個'''',編譯器就不會知道這是一個錯誤,直到(至少)下一行。 – cdarke