8(iii)
Write a Python program that performs the following operations on a list of integers:
- (a)Create a list of integers: [5, 15, 25, 35, 45].
- (b)Append the integer 55 to the list.
- (c)Insert the integer 20 at index 1.
- (d)Remove the integer 35 from the list.
- (e)Find the index of the integer 25 and print it.
- (f)Print the final list.
Show SolutionHide Solution↓
numbers = [5, 15, 25, 35, 45]
numbers.append(55)
numbers.insert(1, 20)
numbers.remove(35)
index_25 = numbers.index(25)
print("Index of 25:", index_25)
print("Final list:", numbers)
Index of 25: 3
Final list: [5, 20, 15, 25, 45, 55]