In: Computer Science
|
print("This program takes three numbers and returns the sum.") total = 0 for i in range(3): x = input("Enter a number: ") total = total + i print("The total is:", x) |
The correct code is:
SOURCE CODE:
*Please follow the comments to better understand the code.
**Please look at the Screenshot below and use this code to copy-paste.
***The code in the below screenshot is neatly
indented for better understanding.
print("This program takes three numbers and returns the sum.")
total = 0
for i in range(3):
# 1. convert x into int type using int()
x = int(input("Enter a number: "))
# 2. add x value, not i value
total = total + x
# 3. we should print the sum, not x value
print("The total is:", total)
===============


