Reputation: 99
I need to create a list of the values between x and y, not including x and y. I'm aware range() can be used to accomplish this. However, I need to be able to do this without knowing whether x or y is greater.
The main problems I'm running into are that range() does not seem to work when the first argument is greater, and I can't know whether to increment x or y in order to make sure x and y are not included.
I'm aware there's a way to do this in several lines with if statements and for loops, however I'm looking for a method that only takes one or two lines, perhaps with a built-in function.
Upvotes: 0
Views: 41
Reputation: 21
You can try using the min max function
for i in range(min(x,y)+1, max(x,y)):
print(i)
Upvotes: 2