¿Quiéres el ejercicio resuelto en menos de 48 horas? Paga desde $US 4 (4 DÓLARES)  vía   PayPal   o   desde  $ 10.000 pesos (colombianos) vía Nequi si estás en Colombia, comunicándote al whatsapp +573203806207 para confirmar pago, y tendrás el ejercicio resuelto.

8.4 Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() method. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, sort and print the resulting words in python sort() order as shown in the desired output.

You can download the sample data at http://www.py4e.com/code3/romeo.txt

 

fname = input("Enter file name: ")
fh = open(fname)
lst = list()
for line in fh:
    word_split = line.split()
    for word in word_split:
        if word not in lst:
            lst.append(word)
        else:
            continue
        lst.sort()
print(lst)
¿Quiéres el ejercicio resuelto en menos de 48 horas? Paga desde $US 4 (4 DÓLARES)  vía   PayPal   o   desde  $ 10.000 pesos (colombianos) vía Nequi si estás en Colombia, comunicándote al whatsapp +573203806207 para confirmar pago, y tendrás el ejercicio resuelto.

Un comentario en “Exercise 8.4 Python For Everybody”

Deja una respuesta