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
1c1,4
< print [x**2 for x in xrange(10)]
---
> tmp = []
> for x in xrange(10):
> tmp.append(x**2)
> print tmp
Unlock
30 remaining solutions by
signing in and submitting your own entry
109 active golfers, 333 entries
42
08/28/2024 at 11:02PM
43
08/28/2024 at 11:02PM
44
08/28/2024 at 11:02PM
45
08/28/2024 at 11:02PM
46
08/28/2024 at 11:02PM
47
08/28/2024 at 11:02PM
48
08/28/2024 at 11:01PM
49
08/28/2024 at 11:01PM
50
08/28/2024 at 11:01PM
51
08/28/2024 at 11:01PM
52
08/28/2024 at 11:01PM
53
08/28/2024 at 11:01PM
54
08/28/2024 at 11:01PM
55
08/28/2024 at 11:01PM
56
08/28/2024 at 11:00PM
57
08/28/2024 at 11:00PM
58
08/28/2024 at 11:00PM
59
08/28/2024 at 10:59PM
60
08/28/2024 at 10:59PM
61
08/28/2024 at 10:59PM
64
08/28/2024 at 10:59PM
65
08/28/2024 at 10:59PM
66
08/28/2024 at 10:59PM
67
08/28/2024 at 10:59PM
69
08/28/2024 at 10:59PM
70
08/28/2024 at 10:59PM
72
08/28/2024 at 10:58PM
73
08/28/2024 at 10:58PM
75
08/28/2024 at 10:58PM
78
08/28/2024 at 10:58PM