Q. Following code prints the given list in ascending order. Modify the code so that the elements are printed in the reverse order of the result produced by the given code.


numbers = list(range(0, 51, 4))

i = 0

while i < len(numbers):

    print(numbers[i], end = " ")

    i += 3

# gives output as : 12 24 36 48


Answer =

numbers = list(range(0, 51, 4))
i = -1
while i > -len(numbers):
    print(numbers[i], end = " ")
    i += -3

Output :-

48 36 24 12 
>>> 


4 Comments

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

Post a Comment

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

Previous Post Next Post