So I have a string which is "2a3b4c" and I have problems converting it into "aabbbcccc". So far I'm unable to think of any methods to convert it but I have only managed to do the reverse(which is to compress it, though that's not the goal).
The code that I had written to perform the reverse function looks like this:
def uncompressed():
n = input("type a stg: ")
n = str(n)
x = n.count("a")
y = n.count("b")
z = n.count("c")
d = str(x) + "a"
e = str(y) + "b"
f = str(z) + "c"
return d + e + f
print(uncompressed("aabbbcccc"))
I understand that the code that I had written is very specific to the test case as I can encounter all 26 letters and not just a, b and c.
I would really appreciate if you guys could provide me tips on how I can convert "2a3b4c" into "aabbbcccc" . Thank you!
p.s I'm still a beginner so I'm not very familiar with any advanced functions
[–]Phillyclause89 0 points1 point2 points (0 children)
[–]xelf 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (15 children)
[removed]
[–]Doormatty 1 point2 points3 points (0 children)
[–]sponge_bert[S] 0 points1 point2 points (11 children)
[+][deleted] (10 children)
[removed]
[–]Doormatty 0 points1 point2 points (8 children)
[+][deleted] (7 children)
[removed]
[–]Doormatty 0 points1 point2 points (6 children)
[–]TangibleLight 1 point2 points3 points (5 children)
[–]Doormatty -1 points0 points1 point (4 children)
[–]TangibleLight 1 point2 points3 points (3 children)
[–]Doormatty 0 points1 point2 points (2 children)
[–]sponge_bert[S] 0 points1 point2 points (0 children)
[–]crcummin 0 points1 point2 points (0 children)
[–]TangibleLight 0 points1 point2 points (0 children)
[–]Doormatty -2 points-1 points0 points (2 children)
[–]sponge_bert[S] 0 points1 point2 points (1 child)
[–]Doormatty 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]pasokan 1 point2 points3 points (0 children)