Skip to content

Fix string indexing #273

Closed
Closed
@certik

Description

@certik

The following code:

def f():
    s: str
    s = "abcdefg"
    print(s[1]) # prints "bcdefg", but should print "b"
    print(s[1:2]) # prints "cdefg", but should print "b"
    print(s[1:3]) # prints "defg", but should print "bc"

f()

Prints (correctly) using CPython:

$ python a.py 
b
b
bc

But with LPython it prints:

$ lpython a.py && ./a.out 
bcdefg
cdefg
defg

We have to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions