Vote count:
0
I am using this function to warp a series of characters (text) in accordance with lineLength. How would I go about replacing every "#" before the split by "&", and every "#" after the split by "=" ?
def warpbar(text, lineLength):
if len(text) <= lineLength:
return text
else:
return text[:lineLength] + '\n' + warpbar(text[lineLength:], lineLength)
What I have:
>> text = "##########"
>> warpbar(text, 5)
#####
#####
What I want:
>> text = "##########"
>> warpbar(text, 5)
&&&&&
=====
asked 45 secs ago
Python regex: replace everything up to, and starting from Nth element
Aucun commentaire:
Enregistrer un commentaire