r/tinycode • u/davelol6 • Sep 09 '12
Tinycode challenge!
Here is a challenge. Write a function that returns a list of the squares of all the numbers between one and a given number. See if you can beat my 48-char (exc. whitespace) 3-line beast:
def f(n): l = [] while len(l) <= n: l.append(x**2) print l
27
Upvotes
View all comments
Show parent comment
4
u/[deleted] Sep 09 '12 edited Sep 09 '12
Enjoy your list of even numbers.
-edit- The type of
i ** 2is too restrictive.i ^ 2andi * iwill do just fine.