实现求平方

list_square = []
for i in range(1,4):
list_square.append(i**2)
print(list_square)

列表推导式

list_square2 = [i**2 for i in range(1,4) if i !=1]
print(list_square2)

posted on 2021-11-03 10:52  嗷呜喵喵  阅读(25)  评论(0编辑  收藏  举报