Absolute N00B Question: Using 1 list to Index another


I’ve just started using Python and I’m trying to understand and answer a question that is

How do I find out who the next person is from People based on the number of results that have come in? I know the answer is Freddie but I don’t know how to get his value to return based on the 5 Results I have

People = ‘Andy, Byron, Camilla, Darren, Eric, Freddie, George, Helen’
Results = [75, 92,68, 100, 88]

Many thanks from an extremely new guy


1 Like

Hello, @Dbee, and welcome to Python Software Foundation Discourse!

When asking questions or offering replies, and you need to post code within these discussions, please format it correctly for posting, so that important details such as indentation are displayed properly. One way to do this is to place lines of three back ticks before and after the code, as follows:

# example code
for i in range(10):
    print("Hello World!")

There is also a </> button at the top of the editing window for formatting code, after it has been selected.

Concerning your question, are you familiar with the Python Built-in functions page in the official documentation? You may especially be interested in the len() function.

We hope you enjoy the discussions here. You might be interested in taking a look at the following pages:

EDITED on March 15, 2022 to reorganize the order of the text.

1 Like

You may also be even more interested in the zip() function.

Additionally, if you’re going to be working with this data, you might want to consider a data structure more appropriate to your problem, since it is easy for multiple lists to get out of sync and not so easy to access the matching data. A dictionary might be more appropriate to your application. If you are given two lists, you can use, for example, the aforementioned zip() and a list comprehension to make one, or other more verbose but perhaps more beginner friendly methods (like a for() loop).

Best of luck!

1 Like