dictionary = {} words = input("Introduce la lista de palabras y traducciones en formato palabra:traducción separadas por comas: ") for i in words.split(','): key, value = i.split(':') dictionary[key] = value phrase = input('Introduce una frase en español: ') for i in phrase.split(): if i in dictionary: print(dictionary[i], end=' ') else: print(i, end=' ')
You can use a dictionary to store the translation. The key is the word in Spanish and the value is the word in English. Then you can use the dictionary to translate the sentence. For example: sentence = "Este es un ejemplo de una frase en español" dictionary = {"español": "english", "este": "this", "un": "a", "