mardi 23 mai 2017

Python for print last value of each if statement

I'm doing a for loop in python, but I don't know how to print the last value of each statement... i.e.(not the actual loop):

a=0
for i in range(0,10):
    if i<2:
        a+= i
    elif i>7:
        a+= i
print a

In there you can see that it will print 9, but I want it to print first 0 then 9

Any way to do this? Thanks in advance.

Current Output

18

Expected output

1
18

Aucun commentaire:

Enregistrer un commentaire