[issue35597] Bug in Python's compiler

Tim Peters report at bugs.python.org
Thu Dec 27 11:34:38 EST 2018


Tim Peters <tim at python.org> added the comment:

`input()` returns a string, not a list.  For input '1010' you're effectively computing this:

>>> int('1' * 8) + int('1' * 2) # = 11111111 + 11
11111122

which is the correct answer.  If you want your input to be a list of integers instead of a string, try, e.g.,

a = input("please enter a binary integer ")
a = list(map(int, a))

----------
nosy: +scoder, tim.peters
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35597>
_______________________________________


More information about the Python-bugs-list mailing list