Re: [Tutor] how to iterate through a dictionary and assign list values?

2013-12-04 Thread Asokan Pichai
On Thu, Dec 5, 2013 at 9:43 AM, Jared Nielsen wrote: > I want to create a dictionary, assign it keys, then iterate through a for > loop and assign the dictionary values from a list. I'm trying this, but > it's not working: > > dictionary = {"one", "two", "three"} > This creates a set. and NOT a di

Re: [Tutor] Generate list-of-transforms

2013-12-04 Thread Danny Yoo
I believe you're asking for the term "Cycle notation". http://en.wikipedia.org/wiki/Cycle_notation On Wed, Dec 4, 2013 at 7:56 PM, R. Alan Monroe wrote: > Given two lists, before and after a sort: > 0 1 2 3 4 > - > before: 3 1 2 5 4 > after: 1 2 3 4 5 > > Is the

Re: [Tutor] Generate list-of-transforms

2013-12-04 Thread xDog Walker
On Wednesday 2013 December 04 19:56, R. Alan Monroe wrote: > This seems like the kind of thing that probably exists, but there > isn't a simple googlable term for searching it out conveniently. Try "sorting algorithm". -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers

Re: [Tutor] how to iterate through a dictionary and assign list values?

2013-12-04 Thread Danny Yoo
On Wed, Dec 4, 2013 at 8:13 PM, Jared Nielsen wrote: > I want to create a dictionary, assign it keys, then iterate through a for > loop and assign the dictionary values from a list. I'm trying this, but > it's not working: > > dictionary = {"one", "two", "three"} > list = [1,2,3] > > Hi Jared, 'd

[Tutor] how to iterate through a dictionary and assign list values?

2013-12-04 Thread Jared Nielsen
I want to create a dictionary, assign it keys, then iterate through a for loop and assign the dictionary values from a list. I'm trying this, but it's not working: dictionary = {"one", "two", "three"} list = [1,2,3] for key in dictionary: for value in list: dictionary[key] = value I

[Tutor] Generate list-of-transforms

2013-12-04 Thread R. Alan Monroe
Given two lists, before and after a sort: 0 1 2 3 4 - before: 3 1 2 5 4 after: 1 2 3 4 5 Is there a well-known algorithm that can give me the list-of-transforms that got me from before to after? e.g.: first-to-zeroth, zeroth-to-second, second-to-first fourth-to-third

Re: [Tutor] Fwd: question about lists

2013-12-04 Thread Steven D'Aprano
On Wed, Dec 04, 2013 at 10:35:46AM +0100, Ismar Sehic wrote: > hello, good people. > i have a pretty urgent question.the situation is like this, i have > following lists, as results of numerous psycopg2 queries, here are two > examples : Ismar, the following don't look like Python lists to me. It'

Re: [Tutor] Fwd: question about lists

2013-12-04 Thread spir
On 12/04/2013 10:35 AM, Ismar Sehic wrote: [...] Your presentation is a bit abscure (to me, at least): it is hard to help you. Maybe you could explain better, and progressively: * what is the purpose of your software, and its context * what are your input data and what they mean, and whether

Re: [Tutor] Fwd: question about lists

2013-12-04 Thread Dave Angel
On Wed, 4 Dec 2013 10:35:46 +0100, Ismar Sehic wrote: so please, i need some pointers in how to get these lists related, regarding i cannot use indexing, because i don't always have the same number of items in list. First question is whether the data is assumed to be self consistent. For

[Tutor] Fwd: question about lists

2013-12-04 Thread Ismar Sehic
hello, good people. i have a pretty urgent question.the situation is like this, i have following lists, as results of numerous psycopg2 queries, here are two examples : for one hotel, id 3628 : 3628 [36L, 317L] - room type id ['DBP', 'DS5'] - room names [Decimal('10.00'), Decimal('17.00'), Dec

Re: [Tutor] need a hint

2013-12-04 Thread Wolfgang Maier
Alan Gauld btinternet.com> writes: > > On 04/12/13 10:22, Wolfgang Maier wrote: > > > > > # instead of senateInfo[lastName] = state, > > # which builds a simple state dictionary > > if lastName in senateInfo: > > senateInfo[lastName].append((firstName, st

Re: [Tutor] need a hint

2013-12-04 Thread Steven D'Aprano
On Tue, Dec 03, 2013 at 09:51:12PM -0600, Byron Ruffin wrote: > I realize the code snippet was bad. It was meant to be pseudo code. I was > on my phone and far from pc. Anyway > > I tried this: > > already_seen = set() > for name in last_names: > if name in already_seen: > print

Re: [Tutor] need a hint

2013-12-04 Thread Alan Gauld
On 04/12/13 03:51, Byron Ruffin wrote: is doing this. Also, it seems to be referencing chars when variable lastName is an item in a list. Thats because you are looping over the name. Loops work on any iterable or sequence. A string is a sequence of chars so you can loop over a string as easi

Re: [Tutor] need a hint

2013-12-04 Thread Alan Gauld
On 04/12/13 10:22, Wolfgang Maier wrote: # instead of senateInfo[lastName] = state, # which builds a simple state dictionary if lastName in senateInfo: senateInfo[lastName].append((firstName, state)) else: senateInfo[lastName] = [(fi

Re: [Tutor] need a hint

2013-12-04 Thread Wolfgang Maier
Byron Ruffin g.austincc.edu> writes: > > > > > > I realize the code snippet was bad.  It was meant to be pseudo code.  I was on my phone and far from pc. Anyway > I tried this:  already_seen = set() > for name in last_names: >     if name in already_seen: >         print("Already seen",

Re: [Tutor] need a hint

2013-12-04 Thread Byron Ruffin
I realize the code snippet was bad. It was meant to be pseudo code. I was on my phone and far from pc. Anyway I tried this: already_seen = set() for name in last_names: if name in already_seen: print("Already seen", name) else: already_seen.add(name) I am not seeing