I have a string that comes from an input, for example, "ABCD"
I also have multiple strings ("0", "1", "2", "3")
that I want to add before each character in "ABCD"
, such that the final result will be "0A1B2C3D"
I've tried using a dictionary and for loop:
text = input()
if len(text) > 4:
return
phrases = {0: "0", 1: "1", 2: "2", 3: "3"}
for i in range(len(text)):
combined = []
combined[i] = phrases[i] + text[i]
print(combined[i])
But I get the following error:
IndexError: list assignment index out of range
How do I go about doing this?