Skip to content

range function accepted with 3 parameters #110

Open
@fbouchet

Description

@fbouchet

In both the course and the reference sheet for Python101, the range function is presented as a function which takes only 2 parameters. To enforce this, it would be a nice enhancement to raise a warning when range is used with 1 (maybe) or 3 (surely) parameters.

It would be particularly useful for cases where one has to iterate in the reverse order: although L[::-1] is accepted for a list, and s[::-1] for a string, I don't believe the following example is considered acceptable in Python101:

def test():
    """->NoneType"""
    #i:int
    for i in range(10,0,-1):
        print(i)
    return None

And it is commonly used by people who know some Python (or search for examples online).

In case I'm incorrect, it's probably the course and reference sheets that would need to be updated to let everyone know that it is acceptable in Python101.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions