嗨,这是我到目前为止
COLS= int(input("Number of Students to enter: "))
ROWS= int(input("Number of Grades per student: "))
number =[]
for c in range(COLS):
grades = []
student =(input("Enter Student ID number "))
number.append(student)
number.append(grades)
count = 1
for r in range (ROWS):
grade = (input("Enter Grade for Module "+str(count)+ ": "))
grades.append(grade)
count = count + 1
print
print (number)
print
print ('Rows and Columns')
print (student) + (grades)
我满意count = count + 1
的所有内容。但我不确定如何打印结果,如
Rows and Columns
123 88 97 66 52
124 77 64 73 65
^^^ 这将是"菜单"如果输入是
No of Students:2
No of grades: 4
student no.= 123
Grade 1 = 88
Grade 2= 97
Grade 3 = 66
Grade 4 = 52
。 菜单的下一行是其他学生输入的。 任何帮助将不胜感激
答案 0 :(得分:0)
您的数据结构不是最佳选择,但是......:
for i in range(len(number)):
# if this element is an int, then following would be the list of grades.
if isinstance(number[i],str):
print(number[i],' '.join(map(str, number[i+1])))