6(iii)
Write a Python program that performs the following operations on a list of integers:
- (a)Create a list of integers: [10, 20, 30, 40, 50].
- (b)Append the integer 60 to the list.
- (c)Insert the integer 25 at index 2.
- (d)Sort the list in ascending order.
- (e)Search for the integer 30 in the list and print its index.
- (f)Print the final list.
Show SolutionHide Solution↓
numbers = [10, 20, 30, 40, 50]
numbers.append(60)
numbers.insert(2, 25)
numbers.sort()
index_30 = numbers.index(30)
print("Index of 30:", index_30)
print("Final list:", numbers)
Index of 30: 3
Final list: [10, 20, 25, 30, 40, 50, 60]