division

kpop snag at jool.po
Sun Jun 22 20:44:54 EDT 2003


Hi, i am writing a maths program where i get input from the user and store
it in
a string. i then use the eval fucntion to return the right answer. users
could type in
"(23+ 21) - (4 * 3) + 2" for example and the function would return an int of
34 which
I would convert to a string. The problem is division, I would like it that
only
exact division was aloud, I mean no remainders.  In python "22 / 5" returs
an int of 5
i would like if that was illegal because 5 doesnt go into 22 , 4 times
exactly, and have the eval
function raise an execption which i could handle.

any advice?
Thanks






More information about the Python-list mailing list