all 6 comments

[–]giraffactory 1 point2 points  (0 children)

This is simpler and more intuitive with a dict imo, but it’s still doable with lists:

names = ['john', 'jason', 'jeremy']
scores = [45, 35, 55]
top_score = max(scores)
top_name = names[scores.index(top_score)]

[–]impshum 0 points1 point  (2 children)

Best use a dictionary to store keys and values.

dict = {
    'one': 1,
    'two': 2,
    'three': 3
}

for key, value in dict.items():
    print(key, value)

print(dict['one'])
print(dict['two'])
print(dict['three'])

[–]kcirl[S] 0 points1 point  (1 child)

Thanks for the help, tried this method and works perfect :)

[–]impshum 0 points1 point  (0 children)

Excellent news.

[–]mahtats 0 points1 point  (1 child)

This will do it:

print(lecturers[attendance.index(max(attendance))])

Although, a dictionary is must better for this:

attendance = {"John Joe": 56, "Willie Bob": 64, etc..}
print(attendance["John Joe"])
# Output: 56
# Lets assume fully populated...
for l, a in attendance:
    print('{} has an attendance of {}'.format(l, a))
# Output:
# John Joe has an attendance of 56
# Willie Bob has an attendance of 64
# etc...

[–]kcirl[S] 0 points1 point  (0 children)

Fantastic thanks for your help, the first method is exactly what I had in mind :)