KnowledgeBoat Logo

Computer Science

Write a program to display the maximum and minimum values from the specified range of indexes of list.

Python

Python List Manipulation

33 Likes

Answer

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

Answered By

18 Likes


Related Questions