I would like to ask the following questions, please:
-
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.
-
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,
Simon