Implement Handling for Negative Range (left > right) in Python's range() Function
Description
Currently, when using Python's range() function with parameters where the start value is greater than the end value (e.g., range(30, 3)), it doesn't provide a default behavior or return value. This issue aims to add handling for such cases by returning -1 as the default value when left > right.
Steps to Reproduce
Call range(30, 3) in Python code.
Note that the return value is currently undefined or not handled.
The default value for positive range() is +1 [Step value]
Logically it should be -1 default if range(left,right) where left>right
Expected Behavior
After implementing the proposed handling, calling range(30, 3) should return -1.
Additional Information
This enhancement will improve the usability and robustness of the range() function, especially in scenarios where input parameters may not meet the traditional range criteria.
Considerations may need to be made for edge cases or special scenarios where the default behavior might differ.
Proposed Solution
Add logic to the range() function or its handling code to check if the start value is greater than the end value. If so, return -1 as the default value.
Tasks
[ ] Implement the logic for handling negative range scenarios in the range() function.
[ ] Write tests to validate the behavior of range(30, 3) after the implementation.
[ ] Update documentation or relevant comments to reflect the new behavior.
Issue Title
Implement Handling for Negative Range
(left > right)
in Python'srange()
FunctionDescription
Currently, when using Python's
range()
function with parameters where the start value is greater than the end value (e.g.,range(30, 3)
), it doesn't provide a default behavior or return value. This issue aims to add handling for such cases by returning -1 as the default value when left > right.Steps to Reproduce
range(30, 3)
in Python code.range()
is +1 [Step value]range(left,right)
where left>rightExpected Behavior
After implementing the proposed handling, calling
range(30, 3)
should return -1.Additional Information
range()
function, especially in scenarios where input parameters may not meet the traditional range criteria.Proposed Solution
Add logic to the
range()
function or its handling code to check if the start value is greater than the end value. If so, return -1 as the default value.Tasks
range()
function.range(30, 3)
after the implementation.Environment
Md template is generated using GPT 3.5 openAI