hi all

i have list like
m = 'ma'
m = list1 * m

wen i run the script i'm getting output like
TypeError: can't multiply sequence by non-int

i need a output like

so plzzzzz help me:(

thanks for a reply Gribouillis

wen i run this ["ma%d" % n for n in range(2, 5)] i m gettin error:
SyntaxError: invalid syntax

You typed wrong, but the way you typed in your message is correct, try again!

IDLE 2.6.6      
>>> ["ma%d" % n for n in range(2, 5)]
['ma2', 'ma3', 'ma4']

(If you copy code to message push first (CODE) or paint the code and push it afterwards.)

You are expecting also wrong result, here is generic way to do your result, but the output is different:

import itertools

m = 'ma'
print(tuple('%s%s' % combination for combination in itertools.product(list1, m)))
""" Output (not what you expected, but logically correct):
('2m', '2a', '3m', '3a', '4m', '4a')

Edited 3 Years Ago by mike_2000_17: Fixed formatting

[ma2, ma3, ma4]
would imply a list of variable names.
You have to let Python know what those variable names represent.

Yes Vegas eater, but expecting variables to come out of the product would be little much.

If the OP, would open his heart and share his dreams, which he want to accomplish together with Great Python, maybe we could help to open the Gate of Heaven ;)

This question has already been answered. Start a new discussion instead.