简体   繁体   English

Python尝试将结果打印为菜单

[英]Python trying to print results as menu

Hi this is what I so far 嗨,这就是我到目前为止

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)

everything up to count = count + 1 i am happy with. 一切都要count = count + 1我很满意。 But i am unsure how to print the results like 但是我不确定如何打印结果

    Rows and Columns
    123 88 97 66 52
    124 77 64 73 65

^^^ that would be the "menu" if the input was ^^^如果输入是,则为“菜单”

No of Students:2
No of grades: 4
student no.= 123
Grade 1 = 88
Grade 2= 97 
Grade 3 = 66
Grade 4 = 52

. and the the next line of the menu would be the other students input. 菜单的下一行将是其他学生的输入。 Any help would be appreciated 任何帮助,将不胜感激

Your data structure is not the best choice, however ...: 您的数据结构不是最佳选择,但是...:

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])))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM