Click here to Skip to main content
15,071,262 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Python
marks = [['john',80, 90, 76, 82],['katy', 50, 55, 70, 65],['sydney',80,
72, 88, 90]]
marks_c = {}
for i in range(len(marks)):
 name = marks[i][0]
 l = []
 for j in range(2,len(marks[i])):
 print(marks[j][i])
 print(marks_c)
print(marks_c)


What I have tried:

Python
marks = [['john',80, 90, 76, 82],['katy', 50, 55, 70, 65],['sydney',80,
72, 88, 90]]
marks_c = {}
for i in range(len(marks)):
 name = marks[i][0]
 l = []
 for j in range(2,len(marks[i])):
print ( marks [j][i])
Posted
Updated 20-Sep-21 21:35pm
v2
Comments
OriginalGriff 21-Sep-21 1:56am
   
What error?
What does it do that you didn't expect, or not do that you did?
What have you tried to do to find out why?
Are there any error messages, and if so, where and when? What did you do to make them happen?

This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.

Try
Python
marks = [['john',80, 90, 76, 82],['katy', 50, 55, 70, 65],['sydney',80,
72, 88, 90]]
marks_c = {}
for i in range(len(marks)):
 name = marks[i][0]
 l = []
 for j in range(2,len(marks[i])):
  print(marks[i][j])
print(marks_c)
print(marks_c)
   
This works, although it is not clear what result you want:
Python
marks = [['john',80, 90, 76, 82],['katy', 50, 55, 70, 65],['sydney',80, 72, 88, 90]]
for i in range(len(marks)):
    print('Marks for', marks[i][0], ':', end='')
    for j in range(1,len(marks[i])):
        print(marks[i][j], ', ', sep='', end='')
    print('')
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900