0

Can anyone tell me how to reverse the output on this code?

start = 0
end = int(input())
 
for num in range(start, end + 1):
     
 
    if num % 2 == 0:
        print(num, end = '''
''')

its supposed to output the even numbers until the input on descending order.

nanofarad
  • 40,330
  • 4
  • 86
  • 117
  • There are some tips on how to create a decreasing sequence in [this answer](https://stackoverflow.com/a/7286366/1424875) and other answers to that question. Please take a look and see whether you can get them to work for your specific problem. An aside - a more terse way to write `end = '''[newline]'''` is `end = '\n'` – nanofarad Jul 16 '22 at 02:38
  • One way is you can change the if condition ```for num in range(end, start-1,-1):``` and the other way is you can take the output in list and reverse the list in the after for loop by using build in list reverse method. – Shamim Jul 16 '22 at 03:32

0 Answers0