+ 1
Why it is always gives me None?? What is the wrong with None?
5 Réponses
+ 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'
+ 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.
+ 1
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ I got it
Thanks
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
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