Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
writing to a file?
#4
I didn't run your code, but just from the code highlighting it is visible that you missed a first double quote (") in "European" (continents list).
Second and third problems are both indentation related. with open() block of code is not inside Main() function, which I believe is what you wanted to do. So now Main() function just assigns the list of continents to continents variable, and that's it.
Then the f.write is not part of the for loop, because it is not indented inside it. Thus f.write runs only once, and it doesn't know what continent is.
Reply


Messages In This Thread
writing to a file? - by oldDog - Aug-19-2018, 11:31 AM
RE: writing to a file? - by Axel_Erfurt - Aug-19-2018, 11:43 AM
RE: writing to a file? - by buran - Aug-19-2018, 11:45 AM
RE: writing to a file? - by j.crater - Aug-19-2018, 11:48 AM
RE: writing to a file? - by oldDog - Aug-23-2018, 01:03 PM
RE: writing to a file? - by buran - Aug-23-2018, 01:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  writing list to csv file problem jacksfrustration 4 181 8 hours ago
Last Post: jacksfrustration
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,620 Sep-27-2022, 01:38 PM
Last Post: buran
  Writing to json file ebolisa 1 1,116 Jul-17-2022, 04:51 PM
Last Post: deanhystad
  Writing to External File DaveG 9 2,816 Mar-30-2022, 06:25 AM
Last Post: bowlofred
  Writing to file ends incorrectly project_science 4 2,928 Jan-06-2021, 06:39 PM
Last Post: bowlofred
  Writing unit test results into a text file ateestructural 3 5,022 Nov-15-2020, 05:41 PM
Last Post: ateestructural
  Writing to file in a specific folder evapa8f 5 3,670 Nov-13-2020, 10:10 PM
Last Post: deanhystad
  Failure in writing binary text to file Gigux 7 4,057 Jul-04-2020, 08:41 AM
Last Post: Gigux
  writing data to a csv-file apollo 1 2,503 Jul-03-2020, 02:28 PM
Last Post: DeaD_EyE
  Writing to File Issue Flash_Stang 3 2,730 Jun-05-2020, 05:14 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020