我试图显示除“姓名”之外的姓名,并试图获得列表中没有“年龄”的平均年龄,最后获得没有“成绩”的平均成绩
我有一个问题,我试图打印列表中没有第一行的名称,而没有弹出或从列表中删除它们
studentDB = [['Name', 'Age', 'Grade'], ['Con', 20, 90.2],
['Juan', 45, 70.2], ['Jed', 39, 100.0]]
while True:
for i in range(len(studentDB)):
print(i, studentDB[i])
print("\n********** Hackathon ***********")
CRUD = """1- Add
2- Delete
3- Edit
4- Print Report
----------------
Enter a number: """
choice = float(input(CRUD))
if (choice == 1):
Name = input("Please Enter your Name: ")
Age = int(input("Please Enter your Age: "))
Grade = float(input("Please Enter your Grade: "))
studentDB.append([Name, Age, Grade])
print(studentDB)
elif (choice == 2):
Del = int(input("Please Enter the row you want to delete: "))
studentDB.pop(Del)
elif (choice == 3):
Del1 = int(input("Please Enter the row you want to delete: "))
Name1 = input("Please Enter your Name: ")
Age1 = int(input("Please Enter your Age: "))
Grade1 = float(input("Please Enter your Grade: "))
studentDB.pop(Del1)
studentDB.insert(Del1,[Name1, Age1, Grade1])
print(studentDB)
elif (choice == 4):
#here is the problem
for s in range(1, len(studentDB)):
print("")
print(f"There are in the {s} student table. The people included in the list are.")
else:
print("Invalid input")
Here is the output that I wanted to do
这是联机编译器:https://www.programiz.com/python-programming/online-compiler/
有很多方法可以解决这个问题。一种方法是在计算年龄或年级的平均数时,使用范围内的起始指数和切片
相关问题 更多 >
编程相关推荐