this worked before...' '.join([`x x` for x in range(1, 6)])

N

notnorwegian

' '.join([`x x` for x in range(1, 6)])

anyone can tell me what im doing wrong?
 
J

John McMonagle

' '.join([`x x` for x in range(1, 6)])

anyone can tell me what im doing wrong?


' '.join(['%s %s' % (str(x), str(x)) for x in range(1,6)])

or

' '.join([str(x)+' '+str(x) for x in range(1,6)])


outputs....

'1 1 2 2 3 3 4 4 5 5'


Is that what you were after ?
 
A

Arnaud Delobelle

John McMonagle said:
' '.join([`x x` for x in range(1, 6)])

anyone can tell me what im doing wrong?


' '.join(['%s %s' % (str(x), str(x)) for x in range(1,6)])

or

' '.join([str(x)+' '+str(x) for x in range(1,6)])


outputs....

'1 1 2 2 3 3 4 4 5 5'


Is that what you were after ?

Or:

' '.join(str(i//2) for i in xrange(2, 13))

?
 
M

Marc 'BlackJack' Rintsch

' '.join([`x x` for x in range(1, 6)])

anyone can tell me what im doing wrong?

I doubt that this worked before because that's a syntax error:

In [84]: ' '.join([`x x` for x in range(1, 6)])
------------------------------------------------------------
File "<ipython console>", line 1
' '.join([`x x` for x in range(1, 6)])
^
<type 'exceptions.SyntaxError'>: invalid syntax

The backticks are syntactic sugar for the `repr()` function and
``repr(x x)`` isn't legal syntax either.

Ciao,
Marc 'BlackJack' Rintsch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top