I wrote this code but it doesn't work it always gives the number zero
tab = []
N=int(input('Entre un nombre '))
for i in range(0,N):
tab.append(int(input('entre un nombre')))
min_valu = tab[0]
for i in range(0,N):
if (min_valu > i ):
min_valu = i
print('la veleur minimale est',min_valu)
CodePudding user response:
You're always on the right track my brother;
Just you've misunderstand doing looping with range
and operator in
:
- As @mousetail responded in comments,
You could not userange
method using justfor i in tab
:
for i in tab:
if (min_valu > i):
min_valu = i
- As @MadPhysicist responded in comments,
You could userange
but accesstab
with indexi
:
for i in range(0,N):
if (min_valu > tab[i]):
min_valu = tab[i]