<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Lists and Tuples
Lists Recap
A list is a sequence of values. These values can be anything
Step1:  You can access a single element in a list by indexing in using brackets. List indexing starts at 0 so to get the first element, you use 0, the second element is 1 and so on.
list[index]
Step2:  You can find the length of a list using len
len(list)
Step3:  You can use negative indexing to get the last element of a list
Step4:  Nested lists
Lists can contain other lists as elements.
This is a convenient alternative to a matrix. You can arrange lists of varying lengths (and contents) in a specific order and you can iterate over the elements (see below).
Step5:  To access an element in a nested list, first index to the inner list, then index to the item.
Example
Step6:  TRY IT
Update the last element in prices to be 21.00 and print out the new result
Step7:  Operators and Lists
The in operator allows you to see if an element is contained in a list
Step8:  You can use some arithmatic operators on lists
The + operator concatenates two lists
The * operator duplicates a list that many times
Step9:  Note
Step10:  Remember slices from strings? We can also use the slice operator on lists
Step11:  Don't forget, you can use the for and in keywords to loop through a list
Step12:  TRY IT
Create a variable called lots_of_sushi that repeats the inexpensive list two times
Step13:  Adding and deleting elements
To add an element to a list, you have a few options
the append method adds an element or elements to the end of a list, if you pass it a list, the next element with be a list (making a list of lists)
the extend method takes a list of elements and adds them all to the end, not creating a list of lists
use the + operator like you saw before
Step14:  You also have several options for removing elements
the pop method takes the index of the element to remove and returns the value of the element
the remove method takes the value of the element to remove
the del operator deletes the element or slice of the list that you give it
del l[1
Step15:  TRY IT
Add 'rock n roll' to sushi_order then delete the first element of sushi_order
List Functions
max will return maximum value of list
min returns minimum value of list
sum returns the sum of the values in a list
len returns the number of elements in a list # Just a reminder
Step16:  TRY IT
Find the average of numbers using list functions (and not a loop!)
Step17:  Aliasing
If you assign a list to another variable, it will still refer to the same list. This can cause trouble if you change one list because the other will change too.
Step18:  To check this, you can use the is operator to see if both variable refer to the same object
Step19:  To fix this, you can make a copy of the list using the list function
list takes a sequence and turns it into a list.
Alternatively you can use the copy() method
Step20:  Tuples
Tuples are very similar to lists. The major difference is that tuples are immutable meaning that you can not add, remove, or assign new values to a tuple.
The creator of a tuple is the comma , but by convention people usually surround tuples with parenthesis.
Step21:  You can create a tuple from any sequence using the tuple function
Step22:  To create a single element tuple, you need to add a comma to the end of that element (it looks kinda weird)
Step23:  You can use the indexing and slicing you learned for lists the same with tuples.
But, because tuples are immutable, you cannot use the append, pop, del, extend, or remove methods or even assign new values to indexes
Step24:  To change the values in a tuple, you need to create a new tuple (there is nothing stopping you from assigning it to the same variable, though
Step25:  You can loop through tuples the same way you  loop through lists, using for in
Step26:  TRY IT
Create a tuple containing 'soy sauce' 'ginger' and 'wasabi' and save it in a variable called accompaniments
Zip
the zip function takes any number of lists of the same length and returns a list of tuples where the tuples will contain the i-th element from each of the lists.
This is really useful when combining lists that are related (especially for looping)
Step27:  Enumerate
While the zip function iterates over two lists, the built-in function enumerate loops through indices and elements of a list.  It returns a list of tuples containing the index and value of that element.
for index, value in enumerate(list)
<ASSISTANT_TASK:>
Python Code:
sushi_order = ['unagi', 'hamachi', 'otoro']
prices = [6.50, 5.50, 15.75]
print(sushi_order)
print(prices)
Explanation: Lists and Tuples
Lists Recap
A list is a sequence of values. These values can be anything: strings, numbers, booleans, even other lists.
To make a list you put the items separated by commas between brackets []
End of explanation
print(sushi_order[0])
print(sushi_order[2])
Explanation: You can access a single element in a list by indexing in using brackets. List indexing starts at 0 so to get the first element, you use 0, the second element is 1 and so on.
list[index]
End of explanation
print(len(sushi_order))
Explanation: You can find the length of a list using len
len(list)
End of explanation
print(sushi_order[-3])
Explanation: You can use negative indexing to get the last element of a list
End of explanation
everyones_order = [['california roll'], ['unagi', 'dragon roll'], sushi_order]
print(everyones_order)
Explanation: Nested lists
Lists can contain other lists as elements.
This is a convenient alternative to a matrix. You can arrange lists of varying lengths (and contents) in a specific order and you can iterate over the elements (see below).
End of explanation
sushi_order[0] = 'caterpillar roll'
print(sushi_order)
Explanation: To access an element in a nested list, first index to the inner list, then index to the item.
Example:
list_of_lists = [[1,2], [3,4], []]
Acess the first index to the inner list and index to the item
python
    inner_list = list_of_lists[1] # [3,4]
    print inner_list[0] # 3 
Or even quicker:
python
    list_of_lists[1][0] # 3
TRY IT
1) To get dragon roll from the sushi order, first we get the second element (index 1) then we get the the second item (index 1)
2) Print california roll from the list everyones_order:
3) Print all items from the second person's order
Mutable Lists
Lists are mutable, that means that you can change elements. 
To assign a new value to an element
my_list = [1, 2, 3]
my_list[0] = 100
End of explanation
prices[-1] = 21.00
print(prices)
Explanation: TRY IT
Update the last element in prices to be 21.00 and print out the new result
End of explanation
sushi_order
print(('hamachi' in sushi_order))
if 'otoro' in sushi_order:
    print("Big spender!")
Explanation: Operators and Lists
The in operator allows you to see if an element is contained in a list
End of explanation
print((sushi_order * 3))
exprep = ['rep'+str(i) for i in range(5)]
exprep
print((prices + sushi_order))
Explanation: You can use some arithmatic operators on lists
The + operator concatenates two lists
The * operator duplicates a list that many times
End of explanation
newprices = prices.copy()
newprices.append(22)
print(newprices)
prices
Explanation: Note: You can only concatenate lists with lists! If you want to add a "non-list" element you can use the append() function.
End of explanation
inexpensive = sushi_order[:2] #takes only the first two elements from list
print(inexpensive)
Explanation: Remember slices from strings? We can also use the slice operator on lists
End of explanation
for item in sushi_order:
    print(("I'd like to order the {}.".format(item)))
    
print("And hold the wasabi!")
for ind, item in enumerate(sushi_order):
    print(("I'd like to order the {0} for {1}.".format(item, prices[ind])))
Explanation: Don't forget, you can use the for and in keywords to loop through a list
End of explanation
lots_of_sushi = inexpensive*2
print(lots_of_sushi)
Explanation: TRY IT
Create a variable called lots_of_sushi that repeats the inexpensive list two times
End of explanation
my_sushis = ['maguro', 'rock n roll']
my_sushis.append('avocado roll')
print(my_sushis)
my_sushis.append(['hamachi', 'california roll'])
print(my_sushis)
my_sushis = ['maguro', 'rock n roll']
my_sushis.extend(['hamachi', 'california roll'])
print(my_sushis)
Explanation: Adding and deleting elements
To add an element to a list, you have a few options
the append method adds an element or elements to the end of a list, if you pass it a list, the next element with be a list (making a list of lists)
the extend method takes a list of elements and adds them all to the end, not creating a list of lists
use the + operator like you saw before
End of explanation
print(my_sushis)
last_sushi = my_sushis.pop(-1)
print(last_sushi)
my_sushis.remove('maguro')
print(my_sushis)
del my_sushis[1:]
print(my_sushis)
Explanation: You also have several options for removing elements
the pop method takes the index of the element to remove and returns the value of the element
the remove method takes the value of the element to remove
the del operator deletes the element or slice of the list that you give it
del l[1:]
End of explanation
numbers = [1, 1, 2, 3, 5, 8]
print((max(numbers)))
print((min(numbers)))
print((sum(numbers)))
print((len(numbers)))
Explanation: TRY IT
Add 'rock n roll' to sushi_order then delete the first element of sushi_order
List Functions
max will return maximum value of list
min returns minimum value of list
sum returns the sum of the values in a list
len returns the number of elements in a list # Just a reminder
End of explanation
sum(numbers)/len(numbers)
Explanation: TRY IT
Find the average of numbers using list functions (and not a loop!)
End of explanation
cooked_rolls = ['unagi roll', 'shrimp tempura roll']
my_order = cooked_rolls
my_order.append('hamachi')
print(my_order)
print(cooked_rolls)
Explanation: Aliasing
If you assign a list to another variable, it will still refer to the same list. This can cause trouble if you change one list because the other will change too.
End of explanation
print((my_order is cooked_rolls))
Explanation: To check this, you can use the is operator to see if both variable refer to the same object
End of explanation
cooked_rolls = ['unagi roll', 'shrimp tempura roll']
my_order = list(cooked_rolls)
my_order.append('hamachi')
print(my_order)
print(cooked_rolls)
Explanation: To fix this, you can make a copy of the list using the list function
list takes a sequence and turns it into a list.
Alternatively you can use the copy() method: my_order = cooked_rolls.copy()
End of explanation
noodles = ('soba', 'udon', 'ramen', 'lo mein', 'somen', 'rice noodle')
print((type(noodles)))
Explanation: Tuples
Tuples are very similar to lists. The major difference is that tuples are immutable meaning that you can not add, remove, or assign new values to a tuple.
The creator of a tuple is the comma , but by convention people usually surround tuples with parenthesis.
End of explanation
sushi_tuple = tuple(my_order)
print(sushi_tuple)
# Remember strings are sequences
maguro = tuple('maguro')
print(maguro)
Explanation: You can create a tuple from any sequence using the tuple function
End of explanation
single_element_tuple = (1,)
print(single_element_tuple)
print((type(single_element_tuple)))
Explanation: To create a single element tuple, you need to add a comma to the end of that element (it looks kinda weird)
End of explanation
print((noodles[0]))
print((noodles[4:]))
# This should throw an error
noodles[0] = 'spaghetti'
Explanation: You can use the indexing and slicing you learned for lists the same with tuples.
But, because tuples are immutable, you cannot use the append, pop, del, extend, or remove methods or even assign new values to indexes
End of explanation
print(sushi_tuple)
sushi_tuple = sushi_tuple[1:] + ('california roll',)
print(sushi_tuple)
Explanation: To change the values in a tuple, you need to create a new tuple (there is nothing stopping you from assigning it to the same variable, though
End of explanation
for noodle in noodles:
    print(("Yummy, yummy {0} and {1}".format(noodle, 'sushi')))
Explanation: You can loop through tuples the same way you  loop through lists, using for in
End of explanation
print((list(zip([1,2,3], [4,5,6]))))
sushi = ['salmon', 'tuna', 'sea urchin']
prices = [5.5, 6.75, 8]
sushi_and_prices = list(zip(sushi, prices))
sushi_and_prices
for sushi, price in sushi_and_prices:
    print(("The {0} costs ${1}".format(sushi, price)))
Explanation: TRY IT
Create a tuple containing 'soy sauce' 'ginger' and 'wasabi' and save it in a variable called accompaniments
Zip
the zip function takes any number of lists of the same length and returns a list of tuples where the tuples will contain the i-th element from each of the lists.
This is really useful when combining lists that are related (especially for looping)
End of explanation
exotic_sushi = ['tako', 'toro', 'uni', 'hirame']
for index, item in enumerate(exotic_sushi):
    print((index, item))
Explanation: Enumerate
While the zip function iterates over two lists, the built-in function enumerate loops through indices and elements of a list.  It returns a list of tuples containing the index and value of that element.
for index, value in enumerate(list):
    ...
End of explanation
<END_TASK>