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

Re: [Tutor] need a hint

2013-12-03 Thread Steven D'Aprano
On Tue, Dec 03, 2013 at 11:55:30AM -0600, Byron Ruffin wrote: > What I am having trouble with is finding a way to say: if lastName appears > more than once, print something. > > I ran a bit of code: > For x in lastname > If lastname = udall >Print something You most certainly did not run t

Re: [Tutor] need a hint

2013-12-03 Thread Byron Ruffin
What I am having trouble with is finding a way to say: if lastName appears more than once, print something. I ran a bit of code: For x in lastname If lastname = udall Print something This prints x twice. I think what I might be hung up on is understanding the ways that I can use a loop. I

Re: [Tutor] need a hint

2013-12-03 Thread Oscar Benjamin
Reposting to the list. Please send your response to the tutor list rather than directly to me. That way you'll get a response more quickly (from someone else). Also can you please write your response below mine like below (rather than top-posting)? On 3 December 2013 06:25, Byron Ruffin wrote: >

Re: [Tutor] need a hint

2013-12-02 Thread Alan Gauld
On 02/12/13 15:18, Wolfgang Maier wrote: You can do so by turning the entries in senateInfo from a list of strings (states) into a list of tuples (first name, state) like this: senateInfo[lastName] = [(firstName, state)] or for pre-existing entries: senateInfo[lastName].append((fi

Re: [Tutor] need a hint

2013-12-02 Thread Wolfgang Maier
Alan Gauld btinternet.com> writes: > > On 02/12/13 11:03, Wolfgang Maier wrote: > > > ... and since you want to be able to resolve ambiguous last names based on > > first names, you will have to store not just the states, but also the first > > names. > > You can do so by turning the entries in

Re: [Tutor] need a hint

2013-12-02 Thread Alan Gauld
On 02/12/13 11:03, Wolfgang Maier wrote: ... and since you want to be able to resolve ambiguous last names based on first names, you will have to store not just the states, but also the first names. You can do so by turning the entries in senateInfo from a list of strings (states) into a list of

Re: [Tutor] need a hint

2013-12-02 Thread spir
On 12/02/2013 03:25 AM, Byron Ruffin wrote: The following program works and does what I want except for one last problem I need to handle. The program reads a txt file of senators and their associated states and when I input the last name it gives me their state. The problem is "Udall". There

Re: [Tutor] need a hint

2013-12-02 Thread Wolfgang Maier
Oscar Benjamin gmail.com> writes: > > On 2 December 2013 02:25, Byron Ruffin g.austincc.edu> wrote: > > > > The following program works and does what I want except for one last problem > > I need to handle. The program reads a txt file of senators and their > > associated states and when I in

Re: [Tutor] need a hint

2013-12-02 Thread Oscar Benjamin
On 2 December 2013 02:25, Byron Ruffin wrote: > > The following program works and does what I want except for one last problem > I need to handle. The program reads a txt file of senators and their > associated states and when I input the last name it gives me their state. > The problem is "Udal