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
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
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
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
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",
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
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
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
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:
>
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
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
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
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
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
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
15 matches
Mail list logo