[Baypiggies] String Attribute

Phu Sam psam1304 at gmail.com
Wed Jul 29 21:05:12 CEST 2015


Correction from my last reply (print statement near the end)


fh=open(file,'r')
lst = list()
for line in fh:
    lst.append(line.split())

# Merge list of lists
slist=[item for sublist in lst for item in sublist]
# Sort list
slist.sort()
print slist     ####   correction from last post
fh.close()


Phu

On Wed, Jul 29, 2015 at 12:01 PM, Phu Sam <psam1304 at gmail.com> wrote:

> Line 7 to 9 in your code do not make sense.
> For example in  line 7, you cannot split 'list' as it is a keyword
>
> Try this:
>
> fh=open(file,'r')
> lst = list()
> for line in fh:
>     lst.append(line.split())
>
> # Merge list of lists
> slist=[item for sublist in lst for item in sublist]
> # Sort list
> slist.sort()
> print line.rstrip()
> fh.close()
>
>
> Phu
>
> On Tue, Jul 28, 2015 at 4:39 PM, <ltc.hotspot at gmail.com> wrote:
>
>>  [image: Boxbe] <https://www.boxbe.com/overview> This message is
>> eligible for Automatic Cleanup! (ltc.hotspot at gmail.com) Add cleanup rule
>> <https://www.boxbe.com/popup?url=https%3A%2F%2Fwww.boxbe.com%2Fcleanup%3Ftoken%3DI07KxbtM55%252BQjgc5o7O%252FykRkRr4DGMlJCx1zsA0hPf8ak7WqQjOGHdWxM9JQj481%252FKKxcWUOuF3BtafIjGm4%252F1CYBYSf%252FWHpCj9LhXxV1jJnf%252B4DFFWW8gyIULP9dS%252BUy8R4hFYgiAhF5ahgbqjBSA%253D%253D%26key%3DEYEB2V971J9rUqgQB1UBTUDFbRnDbLfSIWPR7D9INgE%253D&tc_serial=22116012251&tc_rand=236919732&utm_source=stf&utm_medium=email&utm_campaign=ANNO_CLEANUP_ADD&utm_content=001>
>> | More info
>> <http://blog.boxbe.com/general/boxbe-automatic-cleanup?tc_serial=22116012251&tc_rand=236919732&utm_source=stf&utm_medium=email&utm_campaign=ANNO_CLEANUP_ADD&utm_content=001>
>>
>>
>>
>> Hi Everyone:
>>
>> What is the source of the syntax error to the String Attribute?
>>
>>
>> Go to the following URL links and view a copy of the raw data file code
>> and sample data:
>>
>> 1.) http://tinyurl.com/p2xxxhl
>> 2.) http://tinyurl.com/nclg6pq
>>
>> Here is the desired output:
>>
>> stephen.marquard at uct.ac.za
>> louis at media.berkeley.edu
>> ....
>>
>>
>> Hal
>>
>> Sent from Surface
>>
>>
>> _______________________________________________
>> Baypiggies mailing list
>> Baypiggies at python.org
>> To change your subscription options or unsubscribe:
>> https://mail.python.org/mailman/listinfo/baypiggies
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20150729/307d685b/attachment.html>


More information about the Baypiggies mailing list