Listing 08 - Page 0: No Title

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 08\08.1258 - No Title.py
# Description: No Title
##############################################################################

names = ["Ana", "Carlos", "Maria"]
for attempt in range(3):
    try:
        i = int(input("Type the index you want to print:"))
        print(names[i])
    except ValueError:
        print("Enter a number!")
    except IndexError:
        print("Invalid value, type between 0 and 2")
Click here to download the file