I have managed to code a little snippet in Python which generates a character strip whose length equals the length of another string like so:
title = "This is a string"
concat_str = ""
for i in range (0,len(title)): #len(title) == 16
concat_str += '-'
# resulting string
print(concat_str) # ----------------
Nevertheless, I wish to know whether this is the most pythonic way to implement this. Thanks a lot.
+=on strings in loops isO(n²)and should thus be avoided. Although trivial answers exist for this, the typical transformation would be to make a list and call.appendin the loop. Then do a"".joinafterwards.