Skip to content

Instantly share code, notes, and snippets.

@nickgrier07
Last active June 5, 2019 06:44
Show Gist options
  • Select an option

  • Save nickgrier07/704fd8916eb1e7f5591f5b493a88a493 to your computer and use it in GitHub Desktop.

Select an option

Save nickgrier07/704fd8916eb1e7f5591f5b493a88a493 to your computer and use it in GitHub Desktop.
File Edit Test
green apple
yellow flower
red mitten
happy days
white river
def main():
extra_lines = ["Bald Mountain\n", "Albuquerque NM\n", "Blue Eagles\n"] # lines to be added
with open('Alph.txt', 'r', encoding="UTF-8") as in_file: # saves lines from file as list
file_lines = list(in_file)
pre_saved_lines = file_lines + extra_lines
saved_lines = sorted(pre_saved_lines)
with open('Bet.txt', 'w', encoding="UTF-8") as out_file: # writes the new lines to a file
for line in saved_lines:
out_file.write(line)
if __name__ == '__main__': # initializer
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment