+ 4
[SOLVED] Please what's wrong with this python exercise?
Program to get lease number of an array without using min() function. Why is my output 0 ? https://code.sololearn.com/cTro0R3eC78N/?ref=app
8 Respostas
+ 8
arr = [63, 88, 9, -1, 0]
min_num = arr[0] + 1
for index in arr:
if index < min_num:
min_num = index
print(min_num)
+ 4
print(min(arr))
in your code the variable "num" does not change until all iterations of the loop have passed. add "print (num)" immediately after "num=arr[0]"
+ 3
Иван Чикyнов
thanks.
and why did you add +1 up there ?
+ 3
Then, when rebuilding, min_num will first become equal to the first element of the array
+ 2
Иван Чикyнов Thank you so much 🎅🙂
+ 2
It's printing -1
+ 1
brijal kansara
IT'S BEEN SOLVED 🎅🙂
THAT'S WHY YOU SEE -1
- 1
Poaomm,z
.s,