Last active
August 23, 2021 14:30
-
-
Save drazenz/c3b4faa10ff8271da39fe3cfe3de2d96 to your computer and use it in GitHub Desktop.
How to write lists to a file in Python
This file contains hidden or 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
| cities = ['New York', 'London', 'Singapore'] | |
| with open('output.txt', 'w') as output_file: | |
| for city in cities: | |
| print(city, file=output_file) | |
This file contains hidden or 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
| print("hello") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment