Q. Consider earlier question's code 1, i.e.


i = 0
while i < 10:
    i +=1
    if i % 2 == 0:
        print(i)

Make changes in the code so that it prints values < 10 but not value 10, WITHOUT changing the test condition of while loop.


Answer :-

Program :-

i = 0
while i < 10:
    if i % 2 == 0:
        print(i)
    i += 1

Output :-

0
2
4
6
8

>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post