Skip to content

Instantly share code, notes, and snippets.

@Tylerdclark
Created September 2, 2020 17:28
Show Gist options
  • Save Tylerdclark/306bb14737a03ed281ce2b5ef6c933e5 to your computer and use it in GitHub Desktop.
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.
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