Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I am currently looking for a way in which I can add a underscore in a string generated as such:
>>> bin(1)[2:].zfill(8) '00000001'
I want the string to be '0_0_0_0_0_0_0_1'
'0_0_0_0_0_0_0_1'
How do i add the underscore between each character?
'_'.join(txt)
This can be achieved in multiple ways and has already been answered a lot of times here. Usually people seem to do to some kind of replace operation but there are other ways. Here's how to use the String join() method.
s = "00000001" "_".join(s)
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
'_'.join(txt)?