Hi there
I have some problem in creating a code.

I have two text files one of them is English to spanish.txt and the other is English to Italiani.txt. I have to create language translator to convert an English word to either an Italian word or a Spanish word.

I've tried this code to open 1 txt. file, but I don't know how to open two file in one code and compair the words to find the similar word as explaind above

words_list = []
the_file = file("English to Italiani.txt")
for line in the_file:
        words_list = words_list + line.split()
print words_list

thank you

good	buono
afternoon	pomeriggio
cat	gatto
dog	cane
white	bianco
finish	fine
exit	uscita
fever	febbre
fox	volpe
jump	salto
lazy	pigro
fish	pesci
not	non
under	sotto
pretty	carino
slow	lento
sun	sole
run	corsa
painting	quandro
beautiful	bello
great	grande
flower	fiore
clever	intelligente
house	casa
good	bueno
afternoon	tarde
cat	gato
dog	perro
white	blanco
finish	final
exit	salida
fever	fiebre
fox	zorro
jump	salto
lazy	perezoso
fish	pescados
not	no
under	debajo
pretty	bastante
slow	lento
sun	sol
run	funcionamiento
painting	pintura
beautiful	hermoso
great	grande
flower	flor
house	casa
7 Years
Discussion Span
Last Post by woooee

If you are looking for the same English word in both files, use one set for each file and then you can get the difference or intersection of the sets. http://en.wikibooks.org/wiki/Python_Programming/Sets To read two files, you open the first file, process it (add to the set or whatever), and then close it. Then open the second file and repeat the process http://diveintopython.org/file_handling/file_objects.html

Edited by woooee: n/a

Votes + Comments
Good guidance without ready answer
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.