nick34992
1/12/2017 - 1:53 AM

MITx 600.1x | Week 1 | Python Basics | 2. Core Elements of Programs | Exercise: while: Item 3

MITx 600.1x | Week 1 | Python Basics | 2. Core Elements of Programs | Exercise: while: Item 3

#!/usr/bin/python3

end = 3                # binding global names
total = 0
current = 1

while current <= end:  # define loop
    total += current   # total = total + current
    current += 1       # current = current + 1

print('total =', total)

'''
MITx 600.1x | Week 1 | Python Basics | 2. Core Elements of Programs | Exercise while: Item 3

total = 6
'''