[Tutor] Find the Greatest number out of 3 (Python 3.7.0)
Alan Gauld
alan.gauld at yahoo.co.uk
Tue Oct 6 19:41:46 EDT 2020
On 07/10/2020 00:31, Adam Eyring wrote:
> What's happening is that the print statements output strings.
That should be the *input* functions, not print...
>> number1 = input('Number1: ')
>> number2 = input('Number2: ')
>> number3 = input('Number3: ')
So these are all strings: "423", "23", "43"
And the greater/less than comparisons on strings
are different to numbers!
>> if number3 > number2 and number3 > number1:
>> print('Number 3')
You could rewrite the above to the arguable more readable:
if number 2 < number3 > number1:
print....
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list