share
Stack OverflowHow to concatenate 2 lists
[-6] [2] Mark M
[2019-06-10 15:29:20]
[ python list loops concatenation ]
[ https://stackoverflow.com/questions/56529308/how-to-concatenate-2-lists ]

list_a : ["http://example.com="]

list_b : [3, 4, 777, 888, 99]

Desired result:

['http://example.com=3',
'http://example.com=4',
'http://example.com=777',
'http://example.com=888',
'http://example.com=99']
(3) Did you try something already? Show us what you tried, otherwise you get downvotes and don't learn anything - Vitor Falcão
Why are you storing the address in a list instead of a str? - AdamGold
Looks like is a list of urls @AdamGold - Vitor Falcão
"The web address is the same"... - AdamGold
[0] [2019-06-10 15:34:46] Igor Servulo [ACCEPTED]

Edit

Let's say you have the following lists:

list_a = ['http://example.com=']
list_b = [3, 4, 777, 888, 99]

Than what you need to do is to create a new list called list_c, and then:

for number in list_b:
   list_c.append(list_a[0] + str(number))

Thanks for pointing this out - Igor Servulo
1
[0] [2019-06-10 15:45:47] Jainil Patel
A="http://example.com="
B=[3, 4, 777, 888, 99]
B=[A+str(i) for i in B]
print(B)

changed B array using inplace substitution trick of python.


Hi, and welcome to StackOverflow! Can you elaborate on your answer a little bit? For example, explanations about interesting parts of your code snippet, or links to the documentation? - Richard-Degenne
2