Python adding space between characters in string. Most efficient way
Say I have a string s = 'BINGO'; I want to iterate over the string to
produce 'B I N G O'.
This is what I did:
result = ''
for ch in s:
result = result + ch + ' '
print(result[:-1]) # to rid of space after O
Is there a more efficient way to go about this?
No comments:
Post a Comment