Skip to content

Instantly share code, notes, and snippets.

@drazenz
Last active August 23, 2021 14:30
Show Gist options
  • Select an option

  • Save drazenz/c3b4faa10ff8271da39fe3cfe3de2d96 to your computer and use it in GitHub Desktop.

Select an option

Save drazenz/c3b4faa10ff8271da39fe3cfe3de2d96 to your computer and use it in GitHub Desktop.
How to write lists to a file in Python
cities = ['New York', 'London', 'Singapore']
with open('output.txt', 'w') as output_file:
for city in cities:
print(city, file=output_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment