Created
September 2, 2020 17:28
-
-
Save Tylerdclark/306bb14737a03ed281ce2b5ef6c933e5 to your computer and use it in GitHub Desktop.
spent more time automating spanish assignment than doing it. Just a way to take a comma separated txt file, sort it, and print it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
dir_path = os.path.dirname(os.path.realpath(__file__)) | |
file_object = open(f'{dir_path}/cognates.txt') | |
the_words = [] | |
for line in file_object: | |
formatted_line = line.rstrip().split(',') | |
if formatted_line != ['']: | |
the_words.append(formatted_line) | |
print('English -> Spanish\n') | |
list.sort(the_words) | |
for english, spanish in the_words: | |
print(f'{english} -> {spanish}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment