expand a list comprehension (python)
Please show your way to convert a list comprehension in python to an ordinary for-loop expression!
Start file
print [x**2 for x in xrange(10)]
End file
tmp = [] for x in xrange(10): tmp.append(x**2) print tmp
View Diff
1c1,4 < print [x**2 for x in xrange(10)] --- > tmp = [] > for x in xrange(10): > tmp.append(x**2) > print tmp
Solutions by @igrigorik:
Unlock 1 remaining solutions by signing in and submitting your own entry