Program Console Vignaankosh.com
Execution Panel
Console is empty.
Print alternate elements of list 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.
# Print alternate elements (every other element)
my_list = [10, 20, 30, 40, 50, 60, 70, 80, 90]
print("Original:", my_list)
# Method 1: Slicing with step
alternate = my_list[::2] # start:end:step
print(f"Alternate elements (step 2): {alternate}")
# Method 2: Using loop with step
alt_loop = []
for i in range(0, len(my_list), 2):
alt_loop.append(my_list[i])
print(f"Using loop: {alt_loop}")
# Starting from index 1
alternate_from_1 = my_list[1::2]
print(f"Alternate from index 1: {alternate_from_1}")