mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
str: Implement proper string (instead of byte string) indexing.
Also, support negative indexes.
This commit is contained in:
@@ -10,6 +10,17 @@ print('123' + "456")
|
||||
|
||||
print('123' * 5)
|
||||
|
||||
print('abc'[1])
|
||||
print('abc'[-1])
|
||||
try:
|
||||
'abc'[100]
|
||||
except IndexError:
|
||||
print('caught')
|
||||
try:
|
||||
'abc'[-4]
|
||||
except IndexError:
|
||||
print('caught2')
|
||||
|
||||
# iter
|
||||
print(list('str'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user