Skip to content

Commit c88a9d6

Browse files
committed
tests/basics/deque2.py: Add tests for deque subscript-from-end.
Signed-off-by: Damien George <[email protected]>
1 parent 7e1098b commit c88a9d6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/basics/deque2.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@
3131
d[3] = 5
3232
print(d[3])
3333

34+
# Access the last element via index, when the last element is at various locations
35+
d = deque((), 2)
36+
for i in range(4):
37+
d.append(i)
38+
print(i, d[-1])
39+
40+
# Write the last element then access all elements from the end
41+
d[-1] = 4
42+
print(d[-2], d[-1])
43+
3444
# Accessing indices out of bounds raises IndexError
3545
try:
3646
d[4]

0 commit comments

Comments
 (0)