Negative indexing examples Dry Run in PYTHON

Negative indexing examples is an interactive PYTHON dry run visualizer from the Lists programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Negative indexing examples Program Code

# Negative indexing examples
numbers = [10, 20, 30, 40, 50, 60]
print("List:", numbers)

# Negative indices count from end
print(f"Index -1 (last): {numbers[-1]}")
print(f"Index -2 (second last): {numbers[-2]}")
print(f"Index -3 (third last): {numbers[-3]}")
print(f"Index -6 (first): {numbers[-6]}")

# Slicing with negative indices
print(f"Last 3 elements: {numbers[-3:]}")
print(f"All except last: {numbers[:-1]}")

View the complete Lists programs page.

Program Console Negative indexing examples Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.