this was an excrsize where I am supposed to make a list of random numbers and print the third smallest.
I do not understand why it wont print min_num.
import random
def the_third_smallest():
random_nums = 0
random_lst = []
while random_nums < 20:
random_lst.append(random.randint(1,100))
random_nums += 1
print (random_lst)
min_num = random_lst[0]
sivov = 0
while True:
for num in random_lst:
if num < min_num:
min_num = num
# print(min_num)
new_lst = []
for mispar in random_lst:
if mispar != min_num:
new_lst.append(mispar)
# print(new_lst)
if new_lst == []:
return
if sivov == 2:
return
min_num = new_lst[0]
random_lst = new_lst
sivov += 1
print(min_num)