May I drop list bracket from list?
jeanmichel at sequans.com
Thu Apr 23 13:12:48 CEST 2015
----- Original Message -----
> From: "Peter Otten" <__peter__ at web.de>
> To: python-list at python.org
> Sent: Thursday, 23 April, 2015 12:26:41 PM
> Subject: Re: May I drop list bracket from list?
> subhabrata.banerji at gmail.com wrote:
> > Dear Group,
> > list1=
> > for file in list_of_files:
> > print file
> > fread1=open(file,"r").read()
> > fword=fread1.split()
> > list1.append(fword)
> > Here the list is a list of lists, but I want only one list not
> > list of lists.
> There is also a dedicated extend() method that takes a list (actually
> iterable) and appends all items in that list:
If both list1 and fword are lists, you can also write
list1 = list1 + fword
list1 += fword
-- IMPORTANT NOTICE:
The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
More information about the Python-list