【发布时间】:2015-08-04 03:08:12
【问题描述】:
代码:
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
我不知道为什么,请告诉我。
【问题讨论】:
-
请记住,报告的行是检测到错误的行,不一定是包含错误的行。这是因为换行符在
( )中是有效的,所以如果你缺少),编译器直到(至少)下一行才会知道这是一个错误。