python/clase_6/index.py

14 lines
331 B
Python

try:
lista= ["Hola",1, 7, True]
indice= int(input("Ingrese el numero de indice"))
print(lista[indice])
except ValueError:
print("ingrese un valor entero")
except IndexError :
print(f"ocurrió un error, error de indice")
else:
print(f"el indice es {lista[3]}")
finally:
print("Programa finalizado")