We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
i hope you got it by now, but
the square brackets are at the wrong position...
here we are printing a list ------->(unpacking)
list : i**2 for i in range(n)
where i iterates over the provided range and i**2 is computed out
Syntax:
a=[i**2 for i in range(N)]
print(a)
or in one line:
print([i**2 for i in range(N)])
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Loops
You are viewing a single comment's thread. Return to all comments →
i hope you got it by now, but the square brackets are at the wrong position... here we are printing a list ------->(unpacking) list : i**2 for i in range(n) where i iterates over the provided range and i**2 is computed out Syntax:
a=[i**2 for i in range(N)] print(a)
or in one line: print([i**2 for i in range(N)])