Performance of lists and dictionaries

I would like to ask the following questions, please:

  1. If you look up the nth element in a list, does Python go directly to that element, or does it have to read through the list in order to find the element you want. I guess the answer is pretty obvious, because I guess the answer is that Python will go directly to the nth element in the list. Confirmation that Python supports random, direct access to list elements would be appreciated, please.

  2. Imagine you have a dictionary that looks like this:
    coin_data = {“bitcoin”: “x”, “ethereum”: “y”, “nexo”: “z”}

If I ask Python for coin_data[“ethereum”], will it go straight to the dictionary element for ethereum and return the answer ‘y’, or will it read through all the elements in the dictionary in order to return the answer ‘y’ ?

Thanks in advance,


List:- You can access to any specific item in the list by supplying index number. For example:
Food = [“Pizza”, “Burger”, “Coffee”, “Ice cream”]
The result will be Coffee.

Dictionary:- You can not access an item using index number as items in dictionary are not indexable. You can access to an item by supplying key. For example:

capitals = {“USA”:“Washington”, “UK”:“London”, “France”:“Paris”}


The result will be Washington for both.