Computer Science

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 : 0 12 24 36 48

Python List Manipulation

17 Likes

Answer

numbers = list(range(0, 51, 4))
i = len(numbers) - 1
while i >= 0:
    print(numbers[i] , end = " ")
    i -= 3
Output
48 36 24 12 0

Answered By

10 Likes


Related Questions