<jupyter_start><jupyter_text>2D Lists Indexing**Remember:** - Lists can be used to group different values together - it's just a collection of things.- You can make a list in Python by putting different things in a box of brackets `[]` separated by commas- You can make lists of lists, which are called 2D listsHere we're going to learn how to index lists of lists. Let's use our 2D list of food:<jupyter_code># create 2D list
food = [['apple', 'banana', 'grape', 'mango'], 
        ['lettuce','carrot','cucumber','beet'], 
        ['chicken', 'beef', 'fish', 'pork']]

# print 2D list<jupyter_output><empty_output><jupyter_text>The fruit list is the first element in food. Let's get the fruit list from food:<jupyter_code># get the fruit list from the food list<jupyter_output><empty_output><jupyter_text>What is the length of the first index of food?<jupyter_code># print length of the first index of food<jupyter_output><empty_output><jupyter_text>How can you get the lists fruit and vegetables from the list?<jupyter_code># get fruit and vegetables from the list<jupyter_output><empty_output><jupyter_text>What if we want to get mango from our list? We can get the fruit list and then get mango from the fruit list:<jupyter_code># get the fruit list from food and save it in the variable fruit

# print the fruit list to make sure you got what you wanted

# get mango from the fruit list<jupyter_output><empty_output><jupyter_text>We can also get mango from our list in one line! To do this, we can just index twice. The first index is to get the fruit list, and the second index is to get mango from the fruit list:<jupyter_code># get mango by indexing the food list twice<jupyter_output><empty_output><jupyter_text>How can you get carrot from the food 2D list?<jupyter_code># get carrot from the food 2D list<jupyter_output><empty_output><jupyter_text>Now, try getting fish and pork from the food 2D list:<jupyter_code># get fish and pork from the food 2D list<jupyter_output><empty_output><jupyter_text>Finally, let's make a new list called favorites with your favorite food within each list in food. Print it out afterwards to make sure you did what you want!<jupyter_code># make a list of your favorite fruit, vegetable, and meat

# print favorite<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0752405949256343, 'fraction_numerical': 0.003937007874015748, 'mean_word_length': 5.46045197740113, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '535791', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 721, 'n_tokens_neox': 695, 'n_words': 315, 'path': 'Lessons/Lesson07_2D_Lists_Indexing.ipynb', 'repo_name': 'lechten/curriculum-notebooks', 'size': '2286'}