Lists#
1. Fill the missing pieces#
Fill the ____
parts of the code below.
# Let's create an empty list
my_list = ____
# Let's add some values
my_list.____('Python')
my_list.____('is ok')
my_list.____('sometimes')
# Let's remove 'sometimes'
my_list.____('sometimes')
# Let's change the second item
my_list[____] = 'is neat'
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[1], line 2
1 # Let's create an empty list
----> 2 my_list = ____
4 # Let's add some values
5 my_list.____('Python')
NameError: name '____' is not defined
# Let's verify that it's correct
assert my_list == ['Python', 'is neat']
2. Create a new list without modifiying the original one#
original = ['I', 'am', 'learning', 'hacking', 'in']
# Your implementation here
modified =
assert original == ['I', 'am', 'learning', 'hacking', 'in']
assert modified == ['I', 'am', 'learning', 'lists', 'in', 'Python']
3. Create a merged sorted list#
list1 = [6, 12, 5]
list2 = [6.2, 0, 14, 1]
list3 = [0.9]
# Your implementation here
my_list =
print(my_list)
assert my_list == [14, 12, 6.2, 6, 5, 1, 0.9, 0]