I try to understand how to write the code below using python list comprehension method. In the code I need to concatenate the string with itself times next element in the list assuming that the order is always as [string, int, string int]. Is there a way to rewrite the below code using list comprehension method? Thank you.
def array_translate(arr):
i = 0
mystring = ''
while i < len(arr):
pet = arr[i]
if i + 1 < len(arr):
num = arr[i+1]
arr[i] = pet*num
i += 2
for i in arr:
if not str(i).isdigit():
mystring += "".join(i)
else:
continue
return mystring
print (array_translate(["Cat", 2, "Dog", 3, "Mouse", 1])) # => "CatCatDogDogDogMouse"