Skip to content
Advertisement

How to create a search function of a list with multiple organized elements?

I’m trying to create a function with two inputs (number, people) whereas it searches from a list with multiple organized elements for the correct number and outputs the correct information (which the output is named: user).

Here’s the list:

JavaScript

The number request (not a user-input):

JavaScript

Desired output:

JavaScript

This is what I have at the moment. I’m not sure if I should use split, but then I have no clue what to do next.

JavaScript

If anything is wrong, it is okay to scrap it. I’m a bit confused about where to even start.

Advertisement

Answer

And if you insist on using a Tuple of lists, you should fix the syntax as was advised, which could lead for example to:

JavaScript

That said, a dictionary would be far more relevant to your needs, as per the previous answer.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement