Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

other way of creating a list of perfect squares

Hi there! I am currently explaining a certain exercise to my buddy and part of it consists in creating a list of perfect squares up to root of 64 (included) therefore the list has to look like this [0, 1, 4, 9, 16, 25, 36, 49, 64] My first idea was this

squares=[i*i for i in range(sqrt(64)+1)]

which works but I am now trying to do it in a way so that is not compressed such us

 for i in range(sqrt(64)+1)

But I keep getting this error

 for i in range(sqrt(Integer(64))+Integer(1))
SyntaxError: invalid syntax

Any ideas of what I am doing wrong?