Garrett Garrett - 17 days ago 4x
Python Question

Trying to take input from stdin and convert to integer for sum

Very new to Python.
Trying to take inputs from stdin in the form of numbers ex. 416 2876 2864 8575 9784 and convert to int for sum of all using a loop.

Having a terrible time just converting to int for use in a loop. Would like to get a hint on the integer issue and then try to solve myself. Was trying to test my code to print the integers after conversion.

currently have:

import sys
while (int(n) >= 1):


You probably don't want to use sys.stdin directly. Use raw_input() instead.

line = raw_input("Enter some numbers: ")

total = 0

for n in line.split():
    total = total + int(n)

print "The total is: %d" % total