0

Whats wrong here?

# I want to print minimum Digi in list but can't.it worked for maximum Digit. num=(10,4,8,-2,10,45) for number in num: min= num if number<min: min=number print(min)

21st Jun 2019, 5:31 AM
Ankit Tiwari
Ankit Tiwari - avatar
9 Réponses
+ 5
You are not far away. Try this: num=(10,4,8,-2,10,45) min = num[0] for number in num: if number<min: min=number print(min) To get it work for max is your turn now.
21st Jun 2019, 6:21 AM
Lothar
Lothar - avatar
20th Aug 2019, 7:06 AM
Shadow Ninja[#Inactive]
Shadow Ninja[#Inactive] - avatar
+ 7
See if this answers your question : https://code.sololearn.com/c3pAB35qDKp4/?ref=app
21st Jun 2019, 5:43 AM
Shadow Ninja[#Inactive]
Shadow Ninja[#Inactive] - avatar
+ 6
I am not sure what your question means. Sorry - can you explain me? Thanks!
21st Jun 2019, 12:11 PM
Lothar
Lothar - avatar
+ 2
NUKE Read this: https://www.python-course.eu/python3_blocks.php
22nd Jun 2019, 5:08 AM
Anna
Anna - avatar
0
Lothar I got it.thanks Just a quick Q. Is there anything to do with sequence which condition u put first?
21st Jun 2019, 12:02 PM
Ankit Tiwari
Ankit Tiwari - avatar
0
Lothar i mean my code looks similar to yours,you just rearranged the line! Is there anything to do with it?
22nd Jun 2019, 12:49 AM
Ankit Tiwari
Ankit Tiwari - avatar
0
Nuke, to start you have to set a hipothetical min(or max) value outside the loop then in each step each value is compared with the last result.
22nd Jun 2019, 5:32 AM
Cristian Baeza Jimenez
Cristian Baeza Jimenez - avatar