Hi, I try to convert a tuple into binary number but I keep getting the error like"ord() expected string of length 1 but tuple found"
Can anyone help me in this?

Recommended Answers

All 2 Replies

Got to show some code!

Also, which version of Python are you using?

# Python3 only

tup = (1, 2, 3, 4)
tup_bin = tuple(bin(n) for n in tup)
print(tup_bin)

"""output -->
('0b1', '0b10', '0b11', '0b100')
"""
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.