Reading in integer from stdin in Python
问题 I have the following piece of code where I take in an integer n from stdin, convert it to binary, reverse the binary string, then convert back to integer and output it. import sys def reversebinary(): n = str(raw_input()) bin_n = bin(n)[2:] revbin = "".join(list(reversed(bin_n))) return int(str(revbin),2) reversebinary() However, I'm getting this error: Traceback (most recent call last): File "reversebinary.py", line 18, in <module> reversebinary() File "reversebinary.py", line 14, in