K
khaosyt
If I wanted to get the sum of some numbers (for example: 1 + 2 + 3 + 4 + 5 = 15) from the attached program what do I do? Keep in mind that the print statement prints the integers individually.
integer = 0
denom = 10
again = "y" #sentinel:
while again == "y" or again == "Y":
integer = input("Enter a positive integer: ")
while denom <= integer:
denom = denom*10
while denom > 1:
denom = denom/10
number = integer/denom
integer = integer%denom
print str(number)
again = raw_input("Again? (Y/N): ")
integer = 0
denom = 10
again = "y" #sentinel:
while again == "y" or again == "Y":
integer = input("Enter a positive integer: ")
while denom <= integer:
denom = denom*10
while denom > 1:
denom = denom/10
number = integer/denom
integer = integer%denom
print str(number)
again = raw_input("Again? (Y/N): ")