Ejercicio163

mail@pastecode.io avatar
unknown
python
2 years ago
1.6 kB
66
Indexable
Never
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 25 08:07:01 2021

@author: Quiubs
"""
import sys

#file_dir =  "C:/Users/Quiubs/Desktop/Ejercicio163/words.txt"
file_dir = input("Ingresa la direccion del archivo:\n")
words_array = []
try:
    file_words = open(file_dir, "r")
    words_array = file_words.readlines()
    file_words.close()
except OSError as e:
     print ("El archivo no se pudo abrir, porfavor escribe un nombre de archivo valido")
     sys.exit(0)

try:
    for word in words_array:
        voc_indices = {}
        palabra = word.strip().lower()
        if ('a' in palabra) and palabra.count('a') == 1:
            voc_indices['a'] = palabra.index('a')
    
        if ('e' in palabra) and palabra.count('e') == 1:
            voc_indices['e'] = palabra.index('e')
        
        if ('i' in palabra) and palabra.count('i') == 1: 
            voc_indices['i'] = palabra.index('i')
        
        if ('o' in palabra) and palabra.count('o') == 1:
            voc_indices['o'] = palabra.index('o')
        
        if ('u' in palabra) and palabra.count('u') == 1:  
            voc_indices['u'] = palabra.index('u')
    
        if ('y' in palabra) and palabra.count('y') == 1:
            voc_indices['y'] = palabra.index('y')
        
        if len(voc_indices) == 6:
            if voc_indices['a'] < voc_indices['e'] <  voc_indices['i'] < palabra.index('o') < palabra.index('u') < palabra.index('y'):
                print (palabra)
except:
    print ("Algo salio mal no se que")
    sys.exit(0)