I am trying out the list comprehensions. But I got stuck when I tried to write a list comprehension for the following code.
a = ['x','y','z']
result = []
for i in a:
for j in range(1,5):
s = ''
for k in range(j):
s = s + i
result.append(s)
result
output for this is:
['x', 'xx', 'xxx', 'xxxx', 'y', 'yy', 'yyy', 'yyyy', 'z', 'zz', 'zzz', 'zzzz']
Is it even possible to write a list comprehension for this code? if it is how would you write it?