Re: [Tutor] Okay, this time I tried doing a little research but no luck in solving this one.

2011-11-10 Thread delegbede
If you didn't get any error and you were returned to the prompt as you mentioned, it means pygame has been successfully imported. Try running a pygame command to confirm. If you type pygame at the prompt, it should tell you the location of pygame on your system. Regards. Sent from my BlackBe

Re: [Tutor] longest common substring

2011-11-10 Thread lina
#!/usr/bin/python3 import os.path xrange = range c=['71', '82', '80', '70', '84', '56', '58', '34', '77', '76', '61', '76', '34', '76', '58', '34', '56', '61', '65', '82', '65', '80', '65', '82', '80', '82', '65', '82', '61', '80', '82', '65', '61', '63', '65', '70', '80', '71', '34', '71', '

Re: [Tutor] longest common substring

2011-11-10 Thread lina
On Fri, Nov 11, 2011 at 1:23 AM, Walter Prins wrote: > Hi, > > On 10 November 2011 16:23, lina wrote: >> >> def LongestCommonSubstring(S1, S2): >>        M = [[0]*(1+len(S2)) for i in range(1+len(S1))] >>        longest, x_longest = 0, 0 >>        for x in range(1,1+len(S1)): >>                fo

Re: [Tutor] longest common substring

2011-11-10 Thread lina
On Fri, Nov 11, 2011 at 1:21 AM, Peter Otten <__pete...@web.de> wrote: > lina wrote: > >> Hi, >> >> I tested the one from >> > http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_substring >> >> mainly: >> >> #!/usr/bin/python3 >> >> a=['1','2','3','7'] >> >> b=['2','3','7'

[Tutor] Okay, this time I tried doing a little research but no luck in solving this one.

2011-11-10 Thread Nathaniel Trujillo
Okay this time I think it worked because it said 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] then I typed python at the command prompt and the little >>> came up. Then I typed import pygame but I did not get an error, it just prompted me again like this >>>. Thanks for the

Re: [Tutor] The python implementation of the "class relationship".

2011-11-10 Thread Jerry Zhang
2011/11/11 Alan Gauld > On 10/11/11 09:23, Jerry Zhang wrote: > >> As you know, there are several kinds of relationships between classes in >> the UML -- dependency, association, aggregation, composition. >> > > There are several more besides, but lets not get carried away... :-) > > > Q1. Is th

[Tutor] Okay, this time I tried doing a little research but no luck in solving this one.

2011-11-10 Thread Nathaniel Trujillo
Okay, I typed in python -c "import sys; print sys.version" at the command prompt. I didn't see a prompt ending with %. Instead I saw a prompt ending with >. But here is the message I got. Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\

Re: [Tutor] Okay, this time I tried doing a little research but no luck in solving this one.

2011-11-10 Thread Dave Angel
On 11/10/2011 08:01 PM, Nathaniel Trujillo wrote: Okay, I typed into the command line of version 2.7.2, python -c "import sys; print sys.version". I tried it with and without the quotes. I tried copying the error messages from the command line but it wouldn't let me so I copied them from the pyth

Re: [Tutor] Okay, this time I tried doing a little research but no luck in solving this one.

2011-11-10 Thread Steven D'Aprano
Nathaniel Trujillo wrote: Okay, I typed into the command line of version 2.7.2, python -c "import sys; print sys.version". I tried it with and without the quotes. I tried copying the error messages from the command line but it wouldn't let me so I copied them from the python shell instead. You'

Re: [Tutor] Okay, this time I tried doing a little research but no luck in solving this one.

2011-11-10 Thread Alan Gauld
On 10/11/11 21:27, Nathaniel Trujillo wrote: I decided to try using python version 2.1.3 with pygame version 1.7.1 Why so old? Python 2.1 was about 10 years ago! The current version of PyGame should work with Python v2.6 or 2.7 both readily available from python.org -- Alan G Author of the

[Tutor] Okay, this time I tried doing a little research but no luck in solving this one.

2011-11-10 Thread Nathaniel Trujillo
Okay, I typed into the command line of version 2.7.2, python -c "import sys; print sys.version". I tried it with and without the quotes. I tried copying the error messages from the command line but it wouldn't let me so I copied them from the python shell instead. here is what I got after typing i

Re: [Tutor] sifting through a long program

2011-11-10 Thread Alan Gauld
On 10/11/11 18:58, Nathaniel Trujillo wrote: How do I get to line 362 of a program without counting each line ? Thanks for the help. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman

Re: [Tutor] The python implementation of the "class relationship".

2011-11-10 Thread Alan Gauld
On 10/11/11 09:23, Jerry Zhang wrote: As you know, there are several kinds of relationships between classes in the UML -- dependency, association, aggregation, composition. There are several more besides, but lets not get carried away... :-) Q1. Is there any article or code example on its imp

Re: [Tutor] Okay, this time I tried doing a little research but no luck in solving this one.

2011-11-10 Thread Steven D'Aprano
Nathaniel Trujillo wrote: I decided to try using python version 2.1.3 Nathaniel, that's SIX VERSIONS OLD. That's ancient history. Python 2.1 is missing a lot of important features. Please use at least Python 2.6, 2.7 would be better. I admire your perseverance in the face of adversity. Man

Re: [Tutor] Find all strings that....

2011-11-10 Thread Steven D'Aprano
Alexander Etter wrote: On Nov 10, 2011, at 13:52, Francesco Loffredo wrote: Alexander Etter wrote: Hi. My friend gave me a good wake up exercise which I do not want you to solve for me: find all strings which can be converted to alpha with at most two operations, where alpha is some string co

Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread Prasad, Ramit
From: tutor-bounces+ramit.prasad=jpmorgan@python.org [mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of learner404 Sent: Thursday, November 10, 2011 10:44 AM To: Rich Lovely Cc: Tutor Python Subject: Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

Re: [Tutor] positional output

2011-11-10 Thread Prasad, Ramit
>1) Using string formatting: > >>> print("x{0}x{1}x".format(" " * 38, " " * 9)) You can specify alignment and padding with string formatting too. It just requires you to know the formatting mini-language. >>> 'x{0:>40}x{1:^30}x{2:<40}'.format( 'right', 'center' , 'left' ) 'x

Re: [Tutor] Find all strings that....

2011-11-10 Thread Alexander Etter
On Nov 10, 2011, at 13:52, Francesco Loffredo wrote: > Alexander Etter wrote: >> >> Hi. My friend gave me a good wake up exercise which I do not want you to >> solve for me: find all strings which can be converted to alpha with at most >> two operations, where alpha is some string constant, a

Re: [Tutor] positional output

2011-11-10 Thread Andreas Perstinger
On 2011-11-10 21:54, Cranky Frankie wrote: What is the easiest way in Python 3.x to write output positionally? For example I have one literal I want in column 1, the next one in column 40, the third one in column 50. I've tried usings tabs and I'm not getting what I want. Is it something to do wi

[Tutor] Okay, this time I tried doing a little research but no luck in solving this one.

2011-11-10 Thread Nathaniel Trujillo
I decided to try using python version 2.1.3 with pygame version 1.7.1 (I hope they're compatable) and the livewires version that was available at livewires.org.uk, I think it's version 2.1 . After getting the following error message I tried researching the problem myself at bing.com and then google

Re: [Tutor] positional output

2011-11-10 Thread Dave Angel
On 11/10/2011 03:54 PM, Cranky Frankie wrote: What is the easiest way in Python 3.x to write output positionally? For example I have one literal I want in column 1, the next one in column 40, the third one in column 50. I've tried usings tabs and I'm not getting what I want. Is it something to do

[Tutor] positional output

2011-11-10 Thread Cranky Frankie
What is the easiest way in Python 3.x to write output positionally? For example I have one literal I want in column 1, the next one in column 40, the third one in column 50. I've tried usings tabs and I'm not getting what I want. Is it something to do with C style printf formatting? An example woul

Re: [Tutor] sifting through a long program

2011-11-10 Thread Max S.
Alt+G, or Edit>Go To Line. On Thu, Nov 10, 2011 at 1:58 PM, Nathaniel Trujillo wrote: > How do I get to line 362 of a program without counting each line ? Thanks > for the help. > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change sub

[Tutor] Fwd: sifting through a long program

2011-11-10 Thread Rance Hall
I accidentally replied just to the OP, so I'm forwarding my comments to the list for the record. -- Forwarded message -- From: Rance Hall Date: Thu, Nov 10, 2011 at 1:36 PM Subject: Re: [Tutor] sifting through a long program To: Nathaniel Trujillo On Thu, Nov 10, 2011 at 12:58

Re: [Tutor] sifting through a long program

2011-11-10 Thread Joel Goldstick
if you are using vim type 262G This is a list for python tutoring. People use a variety of text editors. You should google 'how do I go to a specific line in On Thu, Nov 10, 2011 at 1:58 PM, Nathaniel Trujillo wrote: > How do I get to line 362 of a program without counting each line ? Thanks

[Tutor] sifting through a long program

2011-11-10 Thread Nathaniel Trujillo
How do I get to line 362 of a program without counting each line ? Thanks for the help. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How do I get livewires for python version 3.1.1 ?

2011-11-10 Thread Wayne Werner
On Thu, Nov 10, 2011 at 12:01 PM, Wayne Werner wrote: > > On Thu, Nov 10, 2011 at 11:55 AM, Nathaniel Trujillo < > hothottr...@gmail.com> wrote: > >> Could you tell me where I can get a free download of livewires for python >> version 3.1.1 ? And one that does not have a trial period please. I loo

Re: [Tutor] Find all strings that....

2011-11-10 Thread Francesco Loffredo
Alexander Etter wrote: Hi. My friend gave me a good wake up exercise which I do not want you to solve for me: find all strings which can be converted to alpha with at most two operations, where alpha is some string constant, and a substring of at least length three of alpha must be in the ans

Re: [Tutor] Find all strings that....

2011-11-10 Thread Alexander
> On 11/10/11, Original Poster Alexander Etter wrote: >> >> Hi. My friend gave me a good wake up exercise which I do not want you to >> solve for me: find all strings which can be converted to alpha with at most >> two operations, where alpha is some string constant, and a substring of at >> least

[Tutor] My response to How do I get livewires for python version 3.1.1 ?

2011-11-10 Thread Nathaniel Trujillo
I actually am not familiar with python enough to know what code to use. Thanks for the help. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How do I get livewires for python version 3.1.1 ?

2011-11-10 Thread Wayne Werner
On Thu, Nov 10, 2011 at 11:55 AM, Nathaniel Trujillo wrote: > Could you tell me where I can get a free download of livewires for python > version 3.1.1 ? And one that does not have a trial period please. I looked > and looked but all I found was the one for version 2.x. I thought I had the > one f

[Tutor] How do I get livewires for python version 3.1.1 ?

2011-11-10 Thread Nathaniel Trujillo
Could you tell me where I can get a free download of livewires for python version 3.1.1 ? And one that does not have a trial period please. I looked and looked but all I found was the one for version 2.x. I thought I had the one for version 3.1.1 but I guess I was wrong. I don't know if I am direct

Re: [Tutor] getting ImportError: No module named beginners

2011-11-10 Thread Peter Otten
Nathaniel Trujillo wrote: > First I typed help() into the python 3.1.1 interpreter and then I typed > modules to see if there was a beginners module and it wasn't there but > when I went into the > C:\Python31\Lib\site-packages\livewires folder I saw the file beginners.py > right there in front of

Re: [Tutor] longest common substring

2011-11-10 Thread Walter Prins
Hi, On 10 November 2011 16:23, lina wrote: > def LongestCommonSubstring(S1, S2): >M = [[0]*(1+len(S2)) for i in range(1+len(S1))] >longest, x_longest = 0, 0 >for x in range(1,1+len(S1)): >for y in range(1,1+len(S2)): >M[x][y] = M[x-

Re: [Tutor] longest common substring

2011-11-10 Thread Peter Otten
lina wrote: > Hi, > > I tested the one from > http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_substring > > mainly: > > #!/usr/bin/python3 > > a=['1','2','3','7'] > > b=['2','3','7'] > > def LongestCommonSubstring(S1, S2): > M = [[0]*(1+len(S2)) for i in

[Tutor] getting ImportError: No module named beginners

2011-11-10 Thread Nathaniel Trujillo
First I typed help() into the python 3.1.1 interpreter and then I typed modules to see if there was a beginners module and it wasn't there but when I went into the C:\Python31\Lib\site-packages\livewires folder I saw the file beginners.py right there in front of my face. So here is the program I am

Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread learner404
On Thu, Nov 10, 2011 at 4:33 PM, Rich Lovely wrote: > > It looks like your script is being found fine, meaning the problem lies > elsewhere - unless your actual app is called "avcOsxLinux.py, and you > missed renaming it in the error message. Try adding a print statement as > the very first line

Re: [Tutor] Find all strings that....

2011-11-10 Thread Rich Lovely
If you're on linux or OSX, there's /usr/share/dict/words, which has a few thousand words. Although no plurals, which caught me out once. If you're on windows, it's not a hard file to find. On 10 Nov 2011, at 16:14, Alex Hall wrote: > What about just grabbing a bit text file, such as from Proj

[Tutor] longest common substring

2011-11-10 Thread lina
Hi, I tested the one from http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_substring mainly: #!/usr/bin/python3 a=['1','2','3','7'] b=['2','3','7'] def LongestCommonSubstring(S1, S2): M = [[0]*(1+len(S2)) for i in range(1+len(S1))] longest, x_longes

Re: [Tutor] Find all strings that....

2011-11-10 Thread Alex Hall
What about just grabbing a bit text file, such as from Project Gutenberg (sorry for the possibly incorrect spelling)? Or copying the text from a large webpage and pasting it into a text file? On 11/10/11, Alexander Etter wrote: > > > Hi. My friend gave me a good wake up exercise which I do not wa

[Tutor] Find all strings that....

2011-11-10 Thread Alexander Etter
Hi. My friend gave me a good wake up exercise which I do not want you to solve for me: find all strings which can be converted to alpha with at most two operations, where alpha is some string constant, and a substring of at least length three of alpha must be in the answers. So, my question i

Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread Rich Lovely
On 10 Nov 2011, at 15:20, learner404 wrote: > > > On Thu, Nov 10, 2011 at 2:14 PM, Steven D'Aprano wrote: > learner404 wrote: > Hello list! > > - myapp.py is in a "myfolder" folder that the "users" will be able to > download and put anywhere on their Mac. > [...] > > In both cases OSX compla

Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread learner404
On Thu, Nov 10, 2011 at 2:14 PM, Steven D'Aprano wrote: > learner404 wrote: > >> Hello list! >> >> - myapp.py is in a "myfolder" folder that the "users" will be able to >> download and put anywhere on their Mac. >> > [...] > > In both cases OSX complains it can't find the file. >> > > Do you mean

Re: [Tutor] some ideas about some network

2011-11-10 Thread lina
My mistakes, the first generated-data has some problems: the newly uploaded tar.gz one is: https://docs.google.com/open?id=0B93SVRfpVVg3Mjk0YjYzYTMtNzgzZS00NDk4LWI1M2QtNGE5OGZlMjYyNmM5 zip one is https://docs.google.com/open?id=0B93SVRfpVVg3MDYwZWMzYzItYmI4ZC00MmIxLTg0NmMtMzM5MzZkZTAxZjJl The b

Re: [Tutor] some ideas about some network

2011-11-10 Thread lina
On Thu, Nov 10, 2011 at 10:02 PM, Walter Prins wrote: > Hi Lina, > > On 10 November 2011 13:05, lina wrote: >> >> from 10 groups of data  (namely from 1-84) find some pathway, or network. >> >> such as >> Group 1 (file 1): 1 3 8 5 7 4 >> Group 2 (file 2): 2 8 5 7 4 3 4 8 5 7 4 >> >> so we can see

Re: [Tutor] some ideas about some network

2011-11-10 Thread lina
On Thu, Nov 10, 2011 at 10:02 PM, Walter Prins wrote: > Hi Lina, > > On 10 November 2011 13:05, lina wrote: >> >> from 10 groups of data  (namely from 1-84) find some pathway, or network. >> >> such as >> Group 1 (file 1): 1 3 8 5 7 4 >> Group 2 (file 2): 2 8 5 7 4 3 4 8 5 7 4 >> >> so we can see

Re: [Tutor] The python implementation of the "class relationship".

2011-11-10 Thread Jerry Zhang
Thanks for your reply. 2011/11/10 Steven D'Aprano > Jerry Zhang wrote: > >> As you know, there are several kinds of relationships between classes in >> the UML -- dependency, association, aggregation, composition. >> > > "As you know"... no, I'm afraid I don't know. Believe it or not, it is > po

Re: [Tutor] some ideas about some network

2011-11-10 Thread lina
On Thu, Nov 10, 2011 at 10:02 PM, Wayne Werner wrote: > > On Thu, Nov 10, 2011 at 7:05 AM, lina wrote: >> >> Hi, >> >> Thanks all again for your help in previous post. >> >> Here I meet something I am not experienced, about: >> >> from 10 groups of data  (namely from 1-84) find some pathway, or n

Re: [Tutor] some ideas about some network

2011-11-10 Thread Walter Prins
Hi Lina, On 10 November 2011 13:05, lina wrote: > from 10 groups of data (namely from 1-84) find some pathway, or network. > > such as > Group 1 (file 1): 1 3 8 5 7 4 > Group 2 (file 2): 2 8 5 7 4 3 4 8 5 7 4 > > so we can see that the 8 -> 5 -> 7 -> 4 is a pathway. > I'm sorry but I'm not re

Re: [Tutor] some ideas about some network

2011-11-10 Thread Wayne Werner
On Thu, Nov 10, 2011 at 7:05 AM, lina wrote: > Hi, > > Thanks all again for your help in previous post. > > Here I meet something I am not experienced, about: > > from 10 groups of data (namely from 1-84) find some pathway, or network. > > such as > Group 1 (file 1): 1 3 8 5 7 4 > Group 2 (file

Re: [Tutor] how to remove the coming duplication

2011-11-10 Thread lina
On Thu, Nov 10, 2011 at 8:48 PM, Steven D'Aprano wrote: > lina wrote: >> >> Hi, >> >> How to remove the coming duplication, >> >> Here I wrote one (not working): >> >> > a=['2', '5', '7', '5', '5'] > > [...] >> >> I wish to get a is [2,5,7,5] >> >> just remove the coming duplication, not uniqu

Re: [Tutor] The python implementation of the "class relationship".

2011-11-10 Thread Steven D'Aprano
Jerry Zhang wrote: As you know, there are several kinds of relationships between classes in the UML -- dependency, association, aggregation, composition. "As you know"... no, I'm afraid I don't know. Believe it or not, it is possible to be an experienced, good programmer and still know nothing

[Tutor] some ideas about some network

2011-11-10 Thread lina
Hi, Thanks all again for your help in previous post. Here I meet something I am not experienced, about: from 10 groups of data (namely from 1-84) find some pathway, or network. such as Group 1 (file 1): 1 3 8 5 7 4 Group 2 (file 2): 2 8 5 7 4 3 4 8 5 7 4 so we can see that the 8 -> 5 -> 7 ->

Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread Steven D'Aprano
learner404 wrote: Hello list! - myapp.py is in a "myfolder" folder that the "users" will be able to download and put anywhere on their Mac. [...] In both cases OSX complains it can't find the file. Do you mean that AppleScript can't find the file, or that Python can't find the file? Pleas

Re: [Tutor] how to remove the coming duplication

2011-11-10 Thread Steven D'Aprano
lina wrote: Hi, How to remove the coming duplication, Here I wrote one (not working): a=['2', '5', '7', '5', '5'] [...] I wish to get a is [2,5,7,5] just remove the coming duplication, not unique the list. a = [2, 5, 7, 5, 5] b = a[0:1] # slice of the first item only for x in a[1:]: #

Re: [Tutor] how to remove the coming duplication

2011-11-10 Thread Andreas Perstinger
On 2011-11-10 09:26, lina wrote: atoms=[] def fetchonefiledata(infilename): for line in open(infilename,"r"): parts=line.strip().split() atoms=parts[2] print(atoms[0]) First you define "atoms" as an empty list, but in the line atoms

[Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread learner404
Hello list! - myapp.py is in a "myfolder" folder that the "users" will be able to download and put anywhere on their Mac. - users don't have any Python knowledge and I have no idea if there's a python launcher on their mac => trying to make an applescript file in the folder right next to myapp.p

[Tutor] lb4cwpci h5woidb

2011-11-10 Thread Mario Cavett
2sovs4c, 83a6uf6jpq. http://2ufgrfdi6r.blog.com/w64/ 52fdsyt04v hwfqg zzxy9lf1dx, d3xxy67x4 acih3ta8. 7hnkugc99tv waacqm1ao. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Another question about graphics.

2011-11-10 Thread Timo
Op 10-11-11 06:03, Nathaniel Trujillo schreef: I am using python version 2.7.2. I put the version of livewires for python 2.x in the right folder this time and after running the following program I got a different error message. Here they are. program # New Graphics Window # Demonstrates creati

[Tutor] The python implementation of the "class relationship".

2011-11-10 Thread Jerry Zhang
As you know, there are several kinds of relationships between classes in the UML -- dependency, association, aggregation, composition. Q1. Is there any article or code example on its implementation in python? Q2. More specific, in composition model, the container object may be responsible for the h

Re: [Tutor] how to remove the coming duplication

2011-11-10 Thread Peter Otten
Asokan Pichai wrote: > On Thu, Nov 10, 2011 at 2:07 PM, Peter Otten <__pete...@web.de> wrote: > >> Christian Witts wrote: >> >> > def remove_coming_duplication(a_list): >> > return [element for idx, element in enumerate(a_list) if element >> > != >> > a_list[idx-1]] >> >> Beware of nega

Re: [Tutor] how to remove the coming duplication

2011-11-10 Thread Asokan Pichai
On Thu, Nov 10, 2011 at 2:07 PM, Peter Otten <__pete...@web.de> wrote: > Christian Witts wrote: > > > def remove_coming_duplication(a_list): > > return [element for idx, element in enumerate(a_list) if element != > > a_list[idx-1]] > > Beware of negative indices: > > >>> remove_coming_duplica

Re: [Tutor] how to remove the coming duplication

2011-11-10 Thread Peter Otten
Christian Witts wrote: > def remove_coming_duplication(a_list): > return [element for idx, element in enumerate(a_list) if element != > a_list[idx-1]] Beware of negative indices: >>> remove_coming_duplication([1, 2, 1]) [2, 1] # should be [1, 2, 1]

Re: [Tutor] how to remove the coming duplication

2011-11-10 Thread lina
Thanks for all, I found the problems I faced is more tricky than the simple list I gave. Here the list is: a row of numbers, not one number, such as print a_list[1] is: 1 1 9 7 7 9 9 9 print(a_list) is: 617 617 790 571 571 790 790 790 I attached the codes written based on the suggestions al

Re: [Tutor] how to remove the coming duplication

2011-11-10 Thread Asokan Pichai
I was so miffed at not reading the OP's mail carefully that I wrote a one liner. Ok. Here it goes: def no_adjacent_dup(lst): return [ x for x, y in zip(lst, lst[1:]) if x != y] + [lst[-1]] :-) Enjoyed working that one out; but whether it is a good solution Asokan Pichai