How to convert binary tuple to integer in Python

1 Answer

0 votes
tpl = (1, 0, 0, 1, 1, 0, 1)

intval = int("".join(str(val) for val in tpl), 2)

print(intval)



'''
run:

77

'''

 



answered Dec 4, 2022 by avibootz
...