Watch Me Code 2: Tokenize and Parse

Our end-game is a program which reads in a list of numbers separated by a space and then outputs the sum of those numbers.


In [8]:
# what exactly is the type of a space-separated list of numbers?
raw = "12 45 90"
type(raw)

tokens = raw.split(" ")
total = 0
for token in tokens:
    total = total + int(token)

print("You total is: ")
print(total)


You total is: 
147

In [ ]: