[Tutor] Odd result from function call

Alan Gauld alan.gauld at btinternet.com
Fri Jan 7 22:21:11 CET 2011


"Ben Ganzfried" <ben.ganzfried at gmail.com> wrote 

> x = input("First x is: ")
> y = input("First y is: ")

input() reads strings

> compare(x,y)

the character '1' is less than the character '5' so far as Python 
is concerned

> When I do simply compare(10, 5) from the shell, 

You are using integers.
What happens if you use strings?

>>> compare('10','5')

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list