From 1 to 10, let's win 3 times and add them all

Asked 2 years ago, Updated 2 years ago, 19 views

How do I add 3 wins of each number from 1 to 10 in Python?

Source

python

2022-09-22 22:03

2 Answers

In a more pythonic line...

sum(i**3 for i in range(1, 11))


2022-09-22 22:03

sum = 0
for x in range(1, 11):
  sum += x**3
  print (str(x), x**3)

print("total: ",sum)

You can do it like this.


2022-09-22 22:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.