Reputation: 21
word='p'
versions=['down','up','up+']
I was trying for the below output can any one help me please
pdown
pup
pup+
Please any one can suggest how to do ?
Upvotes: 0
Views: 64
Reputation: 137
You can use map
word='p'
versions=['down','up','up+']
word_versions = map(lambda x:word+x,versions)
print word_versions
This way you will have a list named word_versions containing what you want,you can print it or use it.
Upvotes: 0
Reputation:
word='p'
versions=['down','up','up+']
for x in versions:
print (word+x)
Output:
>>>
pdown
pup
pup+
>>>
Upvotes: 0
Reputation: 13458
' '.join([word + v for v in versions])
EDIT:
Since your edit now shows output words on different lines you can try:
for v in versions:
print word + v
Upvotes: 0
Reputation: 19733
try like this:
" ".join("{}{}".format(word,x) for x in versions)
pdown pup pup+
you want in new line:
print "\n".join("{}{}".format(word,x) for x in versions)
pdown
pup
pup+
Upvotes: 2