1 Replies - 485 Views - Last Post: 16 October 2013 - 05:01 AM Rate Topic: -----

#1 vasant_Gowda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-August 13

how to store multiline in a single list

Posted 16 October 2013 - 01:14 AM

Hi friends ,

I have a file which is of the form

examplefile_A.bdf
examplefile_B.bdf
examplefile_C.bdf
examplefile_D.bdf
examplefile_E.bdf

how to store these in a single list

I expect the output of the form
['examplefile_A.bdf', 'examplefile_B.bdf', 'examplefile_C.bdf',' examplefile_D.bdf']
Is This A Good Question/Topic? 0
  • +

Replies To: how to store multiline in a single list

#2 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3809
  • View blog
  • Posts: 13,516
  • Joined: 12-December 12

Re: how to store multiline in a single list

Posted 16 October 2013 - 05:01 AM

There are several ways, one of which is:

names=[line.strip() for line in open('names.txt')]

SO discussion
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1