CBSE Class 11 Computer Science
Question 102 of 104
List Manipulation — Question 16
Back to all questions 16
Question Question 13
Write a program to display the maximum and minimum values from the specified range of indexes of list.
Solution
l = eval(input("Enter the list: "))
start = int(input("Enter start index: "))
stop = int(input("Enter stop index: "))
slice = l[start : stop + 1]
mx = max(slice)
mi = min(slice)
print("Maximum =", mx)
print("Minimum =", mi)Output
Enter the list: [89, 42, 12, 56, 35, 2, 8, 7, 13, 69]
Enter start index: 3
Enter stop index: 8
Maximum = 56
Minimum = 2