feat: completed problem-06.py

This commit is contained in:
baphim
2026-09-13 16:45:56 -04:00
parent f4bcc0a6d3
commit 2b2913cb7f
+10
View File
@@ -1,2 +1,12 @@
# Write a Python program that executes an operation on a list and handles an IndexError exception if the index is out
# of range.
# Defines 'test_list' var with 4 elements, indices 0-3.
test_list = ['a', 'b', 'c', 'd']
# Try printing the 4th index in the list
try:
print(test_list[4])
# Handle the expected IndexError
except IndexError:
# Print an error message
print('That list entry does not exist.')