"prasad rao" wrote in message
news:9e3fac840812252221pe3345bam7e3e3563e050c...@mail.gmail.com...
hello
I am trying to sort a list(I know there is a builtin sort method).
a=[21,56,35,47,94,12]
b=[]
for x in a:
b.append (min(a))
a.remove (min(a))
>>> a
[56, 47, 94]
>>> b
hello I am trying to sort a list(I know there is a builtin sort
method).
a=[21,56,35,47,94,12]
b=[]
for x in a:
b.append (min(a))
a.remove (min(a))
>>> a
[56, 47, 94]
>>> b
[12, 21, 35]
It is not Compleating .Doing only 3 rounds.Why?
By the way how can I view the builtin code
On Thu, Dec 25, 2008 at 12:46 PM, Alan Gauld wrote:
> for d in os.listdir():
> if MyString(d).beginswith():
>
> Which isn't that cumbersome. d is still available for
> subsequent processing and acces to normal string
> methods is still useful , as in:
>
> for d in os.listdir():
> if MyStr
"Kent Johnson" wrote
You could also make this a method of a subclass of string if you
prefer:
class MyString(str):
def beginswith(self, prefixes):
for prefix in prefixes:
if self.startswith(prefix):
return prefix
It's an appealing idea but the extra step of
On 12/25/08, Kent Johnson wrote:
>
> On Wed, Dec 24, 2008 at 4:04 PM, Emad Nawfal (عماد نوفل)
> wrote:
> > Hi Tutors,
> > I want a function that acts like the startswith method, but can take
> > multiple prefixes. As an amateur programmer, I came up with this one, and
> it
> > works fine, but my
2008/12/25 Alan Gauld :
> You could also make this a method of a subclass of string if you prefer:
>
> class MyString(str):
> def beginswith(self, prefixes):
> for prefix in prefixes:
>if self.startswith(prefix):
> return prefix
>
> Now you can create instances of
On Wed, Dec 24, 2008 at 4:04 PM, Emad Nawfal (عماد نوفل)
wrote:
> Hi Tutors,
> I want a function that acts like the startswith method, but can take
> multiple prefixes. As an amateur programmer, I came up with this one, and it
> works fine, but my experience tells me that my solutions are not alwa
"Emad Nawfal (عماد نوفل)" wrote
>> I want a function that acts like the startswith method, but can
>> take
>> multiple prefixes.
Above does a lot more work than necessary. Try:
def beginsWith(word, listname):
for prefix in listname:
if word.startswith(prefix):
return True
On 12/25/08, Bill Campbell wrote:
>
> On Wed, Dec 24, 2008, bob gailer wrote:
> > Emad Nawfal ( ) wrote:
> >> Hi Tutors,
> >> I want a function that acts like the startswith method, but can take
> >> multiple prefixes. As an amateur programmer, I came up with this one,
> >> and it works fi