2. Add the number 4 to the end of the list using two different methods.
3. Add the number 2 in the list at the correct index to get a sequence.
4. Print the list, it should display 0, 1, 2, 3, 4.
5. Create a new list that contains 5, 6, 7 and 8.
6. Add this new list at the end of the integers list.
7. Remove the number 0 from the list.
Right Answer:
# Step 1
integers = [0, 1, 3]
# Step 2
integers.append(4) # Method 1: Using append()
integers += [4] # Method 2: Using += operator
# Step 3
integers.insert(2, 2) # Insert 2 at the correct index to create a sequence
# Step 4
print(integers) # Output: [0, 1, 2, 3, 4]
# Step 5
new_list = [5, 6, 7, 8]
# Step 6
integers.extend(new_list) # Adding the new list at the end of the integers list
# Step 7
integers.remove(0) # Removing the number 0 from the list
print(integers) # Output: [1, 2, 3, 4, 5, 6, 7, 8]