mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
Implement str.count and add tests for it.
Also modify mp_get_index to accept: 1. Indices that are or evaluate to a boolean. 2. Slice indices. Add tests for these two cases.
This commit is contained in:
@@ -3,6 +3,16 @@ print(a.index(1))
|
||||
print(a.index(2))
|
||||
print(a.index(3))
|
||||
print(a.index(3, 2))
|
||||
print(a.index(1, -100))
|
||||
print(a.index(1, False))
|
||||
|
||||
try:
|
||||
print(a.index(1, True))
|
||||
except ValueError:
|
||||
print("Raised ValueError")
|
||||
else:
|
||||
print("Did not raise ValueError")
|
||||
|
||||
try:
|
||||
print(a.index(3, 2, 2))
|
||||
except ValueError:
|
||||
|
||||
Reference in New Issue
Block a user