0

I have a integer value i.e. 1010110. How to treat this value as binary? So that i can find the integer value of that binary value.

rebel_roar
  • 17
  • 4

1 Answers1

0

You can pass a base parameter (2 in this case) to the int function:

s = "1010110"
i = int(s, 2)
# 86
user2390182
  • 72,016
  • 6
  • 67
  • 89