Home > OS >  Trouble arranging numbers in language python help me
Trouble arranging numbers in language python help me

Time:10-22

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)     

enter image description here

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 use range method using just for i in tab :
for i in tab:
    if (min_valu > i):
        min_valu = i
  • As @MadPhysicist responded in comments,
    You could use range but access tab with index i:
for i in range(0,N):
    if (min_valu > tab[i]):
        min_valu = tab[i]
  • Related