Re: [Tutor] Please take a look at this function

2009-12-17 Thread Richard D. Moores
On Thu, Dec 17, 2009 at 19:49, Hugo Arts wrote: > Probably easiest to use a regular expression to fix that particular > thing, as in: > > import re > mult_space = re.compile(r'\s+') > def prestrings2list(a_str): >return [re.sub(mult_space, ' ', x).strip() for x in a_str.split(',')] > > Hugo

Re: [Tutor] Please take a look at this function

2009-12-17 Thread Hugo Arts
On Fri, Dec 18, 2009 at 3:44 AM, Richard D. Moores wrote: > On Thu, Dec 17, 2009 at 18:26, Kent Johnson wrote: >> >> On Thu, Dec 17, 2009 at 7:57 PM, Richard D. Moores >> wrote: >> > def prestrings2list(a_str): >> >     word = "" >> >     list_of_strings = [] >> >     length_of_a_string = len(a

Re: [Tutor] Please take a look at this function

2009-12-17 Thread Dave Angel
Richard D. Moores wrote: def prestrings2list(a_str): word = "" list_of_strings = [] length_of_a_string = len(a_str) for i, char in enumerate(a_str): if i == length_of_a_string - 1: word += char word = word.rstrip() list_of_strings.append

Re: [Tutor] Please take a look at this function

2009-12-17 Thread Richard D. Moores
On Thu, Dec 17, 2009 at 18:26, Kent Johnson wrote: > > On Thu, Dec 17, 2009 at 7:57 PM, Richard D. Moores wrote: > > def prestrings2list(a_str): > >     word = "" > >     list_of_strings = [] > >     length_of_a_string = len(a_str) > >     for i, char in enumerate(a_str): > >     if i == leng

Re: [Tutor] Please take a look at this function

2009-12-17 Thread Kent Johnson
On Thu, Dec 17, 2009 at 7:57 PM, Richard D. Moores wrote: > def prestrings2list(a_str): >     word = "" >     list_of_strings = [] >     length_of_a_string = len(a_str) >     for i, char in enumerate(a_str): >     if i == length_of_a_string - 1: >     word += char >     word =

[Tutor] Please take a look at this function

2009-12-17 Thread Richard D. Moores
def prestrings2list(a_str): word = "" list_of_strings = [] length_of_a_string = len(a_str) for i, char in enumerate(a_str): if i == length_of_a_string - 1: word += char word = word.rstrip() list_of_strings.append(word) elif char ==