0

I'm trying to write a python program that can receive inputs and sum all numbers from the range it creates, and it works normally as it should when user inserts 10 and 20, for example. I need to make it work when the user inputs 20 and 10 (big to small), but the program always returns 0. I have not found this specific question anywhere on the internet.

  • Post your code please – Erik McKelvey Sep 22 '20 at 23:56
  • Please, put a piece of you code so it would be possible to reproduce the problems you are facing. This guide should help: https://stackoverflow.com/help/how-to-ask – Lucas Moreira Sep 22 '20 at 23:57
  • I have destroyed my code because it displeased me and ruined my day. I cannot get a range(20,10) to return anything other than 0, doesn't matter the operation. – Mark Kush Sep 23 '20 at 00:00
  • 1
    @MarkKush: `range(anything)` doesn't return `0`. Your script may return `0` because that's the exit success code (and it presumably raised no exceptions). `range(20, 10)` produces nothing because it's an empty sequence; the duplicate explains how to make it actually descend. – ShadowRanger Sep 23 '20 at 00:02

0 Answers0