Re: [Tutor] Lists of duplicates

2017-03-09 Thread Alex Kleider
On 2017-03-09 06:07, Steven D'Aprano wrote: On Wed, Mar 08, 2017 at 08:29:19PM -0800, Alex Kleider wrote: Things like this can usually be broken down into their component parts but I've been unsuccessful doing so: def f(lst): res = {} for item in lst: method_res = res.setdefaul

Re: [Tutor] Help!! Code ridden with Bugs

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 18:42, Eloka Chima via Tutor wrote: > Is my code okay. > > THERE IS AN ERROR/BUG IN YOUR CODE > Results: Traceback (most recent call last): File "python/nose2/bin/nose2", > line 8, Evidently not. But the error messages are unreadable, please send in plain text. -- Alan G Author o

Re: [Tutor] Help!! Code ridden with Bugs

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 13:28, Eloka Chima via Tutor wrote: > My assignment below is ridden with bugs So tell us what they are don;t make us guess and don't expect us to run code which is by your own admission faulty! If you get error messages post them, in full. If it runs but misbehaves tell us what happen

Re: [Tutor] Help!! Code ridden with Bugs

2017-03-09 Thread Mats Wichmann
On 03/09/2017 12:32 PM, Joel Goldstick wrote: > On Thu, Mar 9, 2017 at 8:28 AM, Eloka Chima via Tutor > wrote: >> I am new to programming but an immersive study in the past few weeks have >> brought me to speed so I can play around with codes but not really mastered >> them.My assignment below

Re: [Tutor] Help!! Code ridden with Bugs

2017-03-09 Thread Eloka Chima via Tutor
Is my code okay. Sent from Yahoo Mail on Android On Thu, 9 Mar 2017 at 7:41 pm, Eloka Chima wrote: Your Code Solution Has Errors THERE IS AN ERROR/BUG IN YOUR CODE Results: Traceback (most recent call last): File "python/nose2/bin/nose2", line 8, in discover() File "/usr/local/lib/pyt

Re: [Tutor] Help!! Code ridden with Bugs

2017-03-09 Thread Eloka Chima via Tutor
Your Code Solution Has Errors THERE IS AN ERROR/BUG IN YOUR CODE Results: Traceback (most recent call last): File "python/nose2/bin/nose2", line 8, in discover() File "/usr/local/lib/python2.7/dist-packages/nose2-0.5.0-py2.7.egg/nose2/main.py", line 300, in discover return main(*args, **kwar

Re: [Tutor] Help!! Code ridden with Bugs

2017-03-09 Thread Sri Kavi
def checkout(self, cash_paid): self.cash_paid = cash_paid if self.cash_paid < self.total: self.total -= self.cash_paid return self.total return "Cash paid is not enough" You cannot return two values. Sri On Thu, Mar 9, 2017 at 6:58 PM, Eloka Chima via Tutor wrot

Re: [Tutor] Help!! Code ridden with Bugs

2017-03-09 Thread Joel Goldstick
On Thu, Mar 9, 2017 at 8:28 AM, Eloka Chima via Tutor wrote: > I am new to programming but an immersive study in the past few weeks have > brought me to speed so I can play around with codes but not really mastered > them.My assignment below is ridden with bugs and I've done so much to get rid

[Tutor] Help!! Code ridden with Bugs

2017-03-09 Thread Eloka Chima via Tutor
I am new to programming but an immersive  study in the past few weeks have brought me to speed so I can play around with codes but not really mastered them.My assignment below is ridden with bugs and I've done so much to get rid of them but to no avail. Below is the project : Create a class cal

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Steven D'Aprano
On Wed, Mar 08, 2017 at 08:29:19PM -0800, Alex Kleider wrote: > The algorithm I came up with is: > def make_sublists_of_duplicates(original_list): > frequency_counter = {} > for item in original_list: > _ = frequency_counter.setdefault(item, 0) > frequency_counter[item] +=

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Steven D'Aprano
On Wed, Mar 08, 2017 at 08:29:19PM -0800, Alex Kleider wrote: > Things like this can usually be broken down into their component parts > but I've been unsuccessful doing so: > > def f(lst): > res = {} > for item in lst: > method_res = res.setdefault(item, []) > res.method

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Steven D'Aprano
On Thu, Mar 09, 2017 at 01:26:26AM +0530, Sri Kavi wrote: > I wrote and submitted the following function: > > def sublist_duplicates(lst): > sublists = [] > for item in set(lst): > sublists.append([item] * lst.count(item)) > return sublists > > lst_of_duplicates = [1, 2, 10,

Re: [Tutor] IMAP Login Error - raise self.error(dat[-1])

2017-03-09 Thread Sreekul Nair
Hi Sri, Thank you so much for the reply. Really appreciate it. I had thought this might be related to the Firewall. However, I connected to VPN and then tried executing the same program. It still ended in error. Few pointers that I would like to bring to your notice. a) The Ping to my mail.o365..

Re: [Tutor] IMAP Login Error - raise self.error(dat[-1])

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 06:05, Sreekul Nair wrote: > Running this simple program ends in following error - > File "C:\Python27\lib\imaplib.py", line 520, in login > raise self.error(dat[-1]) error: LOGIN failed. First thing to test with errors like this is can you login manually over telnet/ssh using the exa

Re: [Tutor] IMAP Login Error - raise self.error(dat[-1])

2017-03-09 Thread Sri Kavi
Must be firewall that’s causing the problem? Here’s a third-party IMAP client library called IMAPClient which is easier to use . You may want to take a look at it. http://imapclient.readthedocs.io/en/stable/ Sri On Thu, Mar 9, 2017 at 11:35 AM, Sreekul Nair wrote: > Dear All, > > I have t

[Tutor] IMAP Login Error - raise self.error(dat[-1])

2017-03-09 Thread Sreekul Nair
Dear All, I have tried to search for related issues in StackOverflow and other python forums but to no avail. And I am really growing desperate to resolve this issue. I am not sure who would be able to help me if not you guys. Its an earnest request to please help me understand what I am doing wro

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Mats Wichmann
On 03/08/2017 12:56 PM, Sri Kavi wrote: > As part of my learning, I was participating in a discussion at: > > > > https://discuss.codecademy.com/t/python-lists-of-duplicated-elements/78151 > > > > It’s about making a function that returns a list of lists, with each list > being all of the ele

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 06:06, Alex Kleider wrote: > It seems you are simply kicking the can down the road rather than > explaining how it it is that dot notation actually works. The dot notation is just a method access. Dictionaries are like any other object and have many methods. > To access a dictionary

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 04:29, Alex Kleider wrote: >> I'd probably opt for a dictionary: >> >> def f(lst): >> res = {} >> for item in lst: >> res.setdefault(item,[]).append(item) >> return list(res.values()) >> > The above works BUT > how setdefault returns the current value for the key

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Peter Otten
Alan Gauld via Tutor wrote: > On 08/03/17 19:56, Sri Kavi wrote: > >> It’s about making a function that returns a list of lists, with each list >> being all of the elements that are the same as another element in the >> original list. > > This is one of those problems where there is probably no