Python SyntaxError: invalid syntax when using if in one line
<p>I tried running the accepted answer from <a href="http://stackoverflow.com/questions/4836710/does-python-have-a-built-in-function-for-string-natural-sort">Does Python have a built in function for string natural sort?</a>, but it gave me the following error:</p>

<pre><code>File " &lt; stdin &gt;", line 4

convert = lambda text: int(text) if text.isdigit() else text 


SyntaxError: invalid syntax
</code></pre>

<p>Can anyone help please?</p>

<p>Thank you...</p>

<hr>

<p>Update:
Thank you everyone for your responses.
I first integrated the code in my own script but received the error. Then I just tested this def on Python interactive window (just this line), and it gives same error.</p>

<p>I am using python/2.6.5. The strange thing is that this code runs on my other computer (Python 2.6.1). Is this code version-specific?</p>
