Reputation: 41
How do I convert ("1,0,1,1,0,0,1,0") to base ten. I keep finding answers for converting lists to base ten but not for when I already have this string
"1,0,1,1,0,0,1,0"
Upvotes: 4
Views: 61
Reputation: 60127
Alternatively you can slice:
int(string[::2], 2)
Upvotes: 1
Reputation: 107287
You can use str.replace and int function :
str.replace
int
>>> s="1,0,1,1,0,0,1,0" >>> int(s.replace(',',''),2) 178