Print and for loop in one line
问题 Is there any alternative one liner for this simple code block: n = int(input()) for i in range(n): print(i**2) I tried: print(i**2 for i in range(int(input()))) It takes an input, but gives the following error: <generator object <genexpr> at 0x00000000032D3E60> My problem is a little bit different than this qs. That qs helped print items in a list whether I need print them in newline. 回答1: As Jon and Patrick mention, that's not an error, it's what happens when you print the __repr__ of a