You can make a simple for
So you scroll through each index by concatenating the "opa"
lista=["oi","meu","nome","é","Gustavo"]
nova_lista = []
for item in lista:
nova_lista.append("opa" + item)
#Mostra o resultado da nova lista
for item in nova_lista:
print(item + "\n")
Or use the map function
Using a lambda expression x: "opa" + x
and returning a list to your new list
lista=["oi","meu","nome","é","Gustavo"]
nova_lista = list(map(lambda x: "opa" + x, lista))
for item in nova_lista:
print(item + "\n")
Use map but return to original list
Instead of returning to a new list, you can continue using the original list with the changed values
lista=["oi","meu","nome","é","Gustavo"]
lista = list(map(lambda x: "opa" + x, lista))
for item in lista:
print(item + "\n")
And with the help of our friend Mário Feroldi, there is another solution using list lambda understanding
lista=["oi","meu","nome","é","Gustavo"]
lista = [f"opa{x}" for x in lista]
for item in lista:
print(item + "\n")
The result of any of the methods is the same:
opaque
opanym
opae
opaGustavo
You use python 2 or 3?
– Wictor Chaves