Python for in range()

sum([i ** 2 for i in range(initial, initial + terms)])

or

sum(map(lambda x: x ** 2, range(initial, initial + terms)))

both will work as the same way.

Leave a Comment