Print times of character
Problem to print the times of characters.
Example-1:
Input : n = "a3b2c1" Output : aaabbc
Example-2:
Input : n = "a2b1c10" Output : aabcccccccccc
Solution
import re n = "a3b2c1" a = re.findall(r'[0-9]+',n) b = [x for x in n if(x.isalpha())] b = "".join(b) d = "" for i in range(len(a)): d += b[i] * int(a[i]) print(d)
Output
aaabbc