Week 5 -File Handling -Write-1

For input number 12, i am unable to get an output.

Thanks & Regards,
Purvi Manghi

is it working with the value [2,22] ??

Similar to cell [10]. It should be written as :


@Ishvinder But in the video its working without using double quotes.

Wait, i shall check it. Will revert soon

Hi @shresth.mishra.cse22,

Sorry, I didn’t took a look at this video earlier, I thought @PURVI was trying to write some characters from string “out_lines” to the file. My bad.

Coming to the actual doubt, i have a few points to add.

  1. In cell 10, please don’t use double quotes around out_lines as it’s a list, and not a string.
  2. Can you please share a link to your notebook, or a screenshot where you assigned out_lines to the list returned by readlines() function.

@Ishvinder thanks ishvinnder. My doubt is cleared.


Dear Ishvinder,

Please find above the link.
Would request you to please show the correct way and re-share the workbook with me.

Thanks & Regards,
Purvi Manghi.

Dear Padhai Team,
Also, while running the below code(given in link)
f_out.writelines(“out_lines”[2]), I am unable to get the 2nd indexed line as my output.

For my query, you may refer to File Handling Write-02-04-2020 Section.

I am unable to share with you my txt file. Hence, pasting the matter on the chat below:

It is the first poem from the collection of poems “Gitanjali” by Rabindranath Tagore.
Thou hast made me endless, such is thy pleasure, this frail vessel thou emptiest again and again,
and fillest it ever with fresh life. This little flute of a reed thou hast carried over hills and dales,
and hast breathed through it melodies eternally new.

It’s because you’re passing out_lines as a string, and it will write ‘t’ in the file only.

Which part of the course we are talking about here? Is it from Foundations of Data Science?