Aug-19-2018, 11:31 AM
Have been trying to learn how to write to a file in Python 3, but i can't seem to get it right. I have created a continents.txt file and a continents.py file both of which are stored in the same directory.
def Main(): continents = ["African", "Antarctic", "Asian", "Australian", European", "North_American", "South_American"] with open("continents.txt", 'w') as f: for continent in continents: f.write(continent + "\n") if __name__ == "__main__": Main()Could someone please tell this old fool where i am going wrong please.