if i input A9 output AAAAAAAAA but i input A10 program will be error index out of range. how to fix the program when im input A10 or above the program is workly. This my code
Char = input ("Input Char : ")
Total = len(Char)
Decompress =""
for i in range (0, Total,2):
Loop = int(Char[i+1])
for j in range (0, Loop):
Decompress = Decompress + Char [i]
print("Output : ",Decompress)
You don't need a loop (or two loops!) here.
Simply multiply the string:
output:
more generic input
assuming you want to handle repeated pairs of char(s)/digits, this is quite easy to achieve with a regex:
example: