python – How to get the lowest value in a list?

Question:

I'm stuck in this program, I can't create a function in Python.

The exercise is as follows:

Write a function called fetchSmallest() that takes a list of integers and returns the smallest of the elements. Also write the main program that passes the list to the function and displays the return. The search for the smallest element must be performed using a repetition structure, and the use of the min() function is prohibited. Example:

In: 7.0 5.5 6.0 9.0 Out: 5.5

What have I done so far:

``````listaInteiros = []
i = 0

while i < 4:
inteiros = int(input())
listaInteiros.append(inteiros)
i += 1
print(listaInteiros)

def buscarMenor():
``````

I'm stuck in the function, give me a hand please!

Suggestion:

``````def buscarMenor(lst):
i = float("inf")
for nr in lst:
if nr < i:
i = nr
return i

listaInteiros = [7, 5, 6, 9]
menor = buscarMenor(listaInteiros)
print(menor) # 5

listaDecimais = [7.0, 5.5, 6.0, 9.0]
• give the greatest possible value in the declaration/attribution of `i`
• if the iterated number is less than `i` , replace the `i` with that