I'm writing code to make it like this, but it got stuck while writing no1~5 below.
score = [88,95,70,100,99]
classes = ["Korean", "Math", "Science", "Physics", "Chemistry"]
for i, value in enumerate(score, 1):
print("No{}: {}Score-{}".format(i, classes, value))
The code was written as above
No1: ['Korean', 'Mathematics', 'Science', 'Physics', 'Chemistry'] Score -88
No.2: ["Korean", "Mathematics", "Science", "Physics", "Chemistry"] Score - 95
No.3: ["Korean", "Mathematics", "Science", "Physics", "Chemistry"] Score - 70
No 4: [Korean, Math, Science, Physics, Chemistry] Score - 100
No 5: ["Korean", "Math", "Science", "Physics", "Chemistry"] Score - 99
The above results were derived. If you know a solution, please answer.
python loops
# in print
classes # X
classes[i-1] # O
You can also use zip
together.
score = [88,95,70,100,99]
classes = ["Korean", "Math", "Science", "Physics", "Chemistry"]
for i, (v, c) in enumerate(zip(score, classes), 1):
print("No{}: {}Score-{}".format(i, c, v))
© 2024 OneMinuteCode. All rights reserved.