hello everyone, help me I can't solve it. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

hello everyone, help me I can't solve it.

How to do the maximum and minimum of the program. for example input 5 -> array input 2 1 3 5 8 in this set I will get the second value this 1

29th Dec 2020, 10:13 PM
Aid
Aid - avatar
4 Answers
+ 4
I have an example here which will help you get started. It uses a random number generator, then inserts those numbers into a list whose size has been determined by your input. The code then prints the list,& prints the min of the list. See if you can print the max of the list from random import randint as r list_size = int(input()) lst = [] for i in range(list_size): lst.append(r(1,9)) print(lst) print(f'smallest number -> {min(lst)}')
30th Dec 2020, 2:29 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Rik Wittkopp thanks 😊
30th Dec 2020, 4:13 AM
Aid
Aid - avatar
+ 2
your_list = [2, 6, 8, 45, 6, 0, 3] #smallest number in the list : print(min(your_list)) #largest number in the list : print(max(your_list))
30th Dec 2020, 4:12 AM
Ali Bin Faizan
Ali Bin Faizan - avatar