Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:
You typed `int_y = int(2.8)`, so you passed the floating point number 2.8, which the int() function rounds down to 2. On the other hand when y had the string value '2.8'. The int(y) call tried to parse an integer out of the string, but failed since there were numbers after the decimal point. Passing a float rounds down: >>> int(2.8) 2 Passing a string with numbers after the decimal raises ValueError: >>> int('2.8') ValueError: invalid literal for int() with base 10: '2.8' Passing a string of digits without a decimal correctly parses an integer: >>> int('42') 42 Note that the input() function always returns a string, so input() can return '2.8', but not 2.8. ---------- nosy: +Dennis Sweeney _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44866> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com