[Tutor] Find the Greatest number out of 3 (Python 3.7.0)

Chris Roy-Smith chris_roysmith at internode.on.net
Tue Oct 6 20:22:42 EDT 2020


On 7/10/20 10:41 am, Alan Gauld via Tutor wrote:
> 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"
> 
forgive me Alan,
should the inputs be converted to numbers e.g.

number1=int(input('Number1: ')
number2=int(input('Number2: ')
number3=int(input('Number3: ')

> 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....
> 
> 
regards,
ChrisRoy-Smith


More information about the Tutor mailing list