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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…