我想将Talha Ali添加到学生名单中。我已经完成了一项功能,但不知道该怎么回来添加学生。
Students=[("Abdul Saboor , 14007"), ("Anila Jaffer , 14014")]
def add_student(Studentname,Roll ):
'''(Student name,Roll Number) -> Student name,Roll Number
Adds student to the Students list
>>> add_student(Talha Ali,Bsee 13050)
Talha Ali , Bsee 13050
'''
return
答案 0 :(得分:0)
您可以使用追加方法:
def add_student (studentname, roll):
s = (studentname,roll)
students.append(s)
return students
检查以下链接以获取有关数据结构的更多信息: https://docs.python.org/3/tutorial/datastructures.html