Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread Christian Witts
On 2011/11/10 09:10 AM, lina wrote: Hi, How to remove the coming duplication, Here I wrote one (not working): a=['2', '5', '7', '5', '5'] for i in range(len(a)-1): if a[i+1]==a[i]: a.remove(a[i+1]) if i not in range(len(a)): break a

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread delegbede
You have the error because the square brackets are missing. You should have done this: b=[b.append(a[i]) for i in range(len(a)) if a[i] != b[-1]] This would however give you an index out of range error. That said, may I ask what it is exactly you are trying to achieve? Cheers. Sent from my B

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread spawgi
Hello, list.remove will remove the first occurrence of the value from the list. So the output is expected as far as Python is concerned. May be you should think about using pop function. Please take a look at the code below >>> def RemoveComingDuplicates(a): for i in range(len(a)-1): print i,i+

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread delegbede
Try this >>> a=['2', '5', '7', '5', '5'] >>> d=list(set(a)) >>> d ['2','5','7'] Is there any reason why your numbers are in quotes??? Hope this helps. Sent from my BlackBerry wireless device from MTN -Original Message- From: lina Sender: tutor-bounces+delegbede=dudupay@python.or

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread Asokan Pichai
Bad to reply to my own post. Failed to understand the >> just remove the coming duplication, not unique the list. Sorry; ignore my ideas Asokan Pichai ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.p

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread lina
>>> for i in range(len(a)): if i == 0: b.append(a[i]) if a[i]!=b[-1]: b.append(a[i]) This one seems work, but looks clumsy, Thanks for any suggestions that helps to improve. Best regards, ___ Tutor mailli

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread Asokan Pichai
On Thu, Nov 10, 2011 at 12:40 PM, lina wrote: > Hi, > > How to remove the coming duplication, > > Here I wrote one (not working): > > > >>> a=['2', '5', '7', '5', '5'] > >>> for i in range(len(a)-1): >if a[i+1]==a[i]: >a.remove(a[i+1]) >if i not in range(len(a)): >

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread lina
b = [] b=b.append(a[i]) for i in range(len(a)) if a[i] != b[-1] showed me: SyntaxError: invalid syntax ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] how to remove the coming duplication

2011-11-09 Thread lina
Hi, How to remove the coming duplication, Here I wrote one (not working): >>> a=['2', '5', '7', '5', '5'] >>> for i in range(len(a)-1): if a[i+1]==a[i]: a.remove(a[i+1]) if i not in range(len(a)): break >>> a ['2', '7', '5', '5'] I wish

[Tutor] Another question about graphics.

2011-11-09 Thread Nathaniel Trujillo
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 creating a graphics window from livewires import games

[Tutor] Question about graphics.

2011-11-09 Thread Nathaniel Trujillo
I installed livewires for python 2.x so should that work with python version 2.7.2 ? I typed in the code you see below and got the following error message. Here is the code. from livewires import games and here is the error message Traceback (most recent call last): File "C:/Python27/new_grap

Re: [Tutor] Another question about GUI applications.

2011-11-09 Thread Albert-Jan Roskam
Thank you. I looked it up and http://www.python.org/dev/peps/pep-0008/ says the following: Class Names   Almost without exception, class names use the CapWords convention.   Classes for internal use have a leading underscore in addition. Package and Module Names   Modules should hav

Re: [Tutor] Another question about GUI applications.

2011-11-09 Thread Wayne Werner
On Wed, Nov 9, 2011 at 6:26 AM, Albert-Jan Roskam wrote: > Ah, good that they've renamed it to lowercase. Isn't there a convention > to only use a capital for class names? (and of course for constants, which > are all caps). > I think so, I know to adhere PEP 8 that is definitely required for na

Re: [Tutor] Another question about GUI applications.

2011-11-09 Thread Albert-Jan Roskam
Ah, good that they've renamed it to lowercase. Isn't there a convention to only use a capital for class names? (and of course for constants, which are all caps). Cheers!! Albert-Jan ~~ All right, but apart from the sanitation