+ 1

Why it is always gives me None?? What is the wrong with None?

https://code.sololearn.com/cKC4tEdx722k/?ref=app

15th Oct 2021, 1:27 AM
Ahmad Mohammad
Ahmad Mohammad - avatar
5 Answers
+ 2
Ahmad Mohammad First mistake you have assigned None to smallest and largest even they are integer variable. Try to print this because smallest and largest are None print(float(None)) Second mistake what is done here? Without single quotes it will be a variable which is undefined. I think done will be a string So change smallest = 0 and largest = 0 And num == 'done'
15th Oct 2021, 3:02 AM
A͢J
A͢J - avatar
+ 1
Ahmad Mohammad None is used to define a null variable or an object. None is an object which is a type of the class NoneType. Just print this and see: print (type(None)) 1 - None is not the same as False 2 - None is not 0 3 - None is not an empty string 4 - Comparing None to anything will always return False So float (None) will give error because None is an object if you compare with None then result will be False so 123.0 > None #False In your case float(smallest) or float (largest) will give error because you are casting object with a float.
15th Oct 2021, 9:11 AM
A͢J
A͢J - avatar
15th Oct 2021, 10:09 AM
Ahmad Mohammad
Ahmad Mohammad - avatar
0
Jay Matthews it has some errors but the big problem that i got was with the None! I can't change the type of it and i can't do = or > or < between it and another variables
15th Oct 2021, 2:08 AM
Ahmad Mohammad
Ahmad Mohammad - avatar
0
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ I am just answering the question the Dr want me to give a value of None And about done yes it is a string so when the user inter done the program stops I will try print(float(None)) Thank you
15th Oct 2021, 7:28 AM
Ahmad Mohammad
Ahmad Mohammad - avatar