Skip to content
Advertisement

How to append element of same index from a list to another list multiple times?

I have 2 lists of equal lengths as follows

JavaScript

How do I make a single list with the desired outcome be:

JavaScript

I have tried:

JavaScript

but this gives an output:

JavaScript

Advertisement

Answer

You’ll want:

JavaScript

Because you need to split up the first string before you can add the desired suffix to it. Then, re-join the split string together.

Also, try not to shadow list, it’s a built-in, so list3 is a better name for it

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement