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
On 03/12/13 12:55, Rafael Knuth wrote:
Now I want to enhance that program a bit by adding the most popular
country in each year. Here's what I want to get as the output:
In 2009 there were 115 backpackers worldwide and their most
popular country was Brazil.
...
From all my iterations
On 03/12/2013 16:15, Steven D'Aprano wrote:
On Tue, Dec 03, 2013 at 04:04:33PM +, Mark Lawrence wrote:
On 03/12/2013 15:51, Steven D'Aprano wrote:
Here's a modification to your earlier code using zip:
PopularCountries = ["Brazil", "China", "France", "India", "Vietnam"]
Backpackers = 1
On Tue, Dec 03, 2013 at 04:04:33PM +, Mark Lawrence wrote:
> On 03/12/2013 15:51, Steven D'Aprano wrote:
> >
> >Here's a modification to your earlier code using zip:
> >
> >PopularCountries = ["Brazil", "China", "France", "India", "Vietnam"]
> >Backpackers = 100
> >msg = "In %d there were %
On 03/12/2013 15:51, Steven D'Aprano wrote:
Here's a modification to your earlier code using zip:
PopularCountries = ["Brazil", "China", "France", "India", "Vietnam"]
Backpackers = 100
msg = "In %d there were %d backpackers worldwide and their most popular country was
%s."
for year, countr
On Tue, Dec 03, 2013 at 04:03:55PM +0100, Rafael Knuth wrote:
> Hej there,
>
> > That's very poor coding, if you're given a function that does exactly what
> > you want, why rewrite it and worse still, get it wrong?
>
> I don't quite understand. I took that advice, tried it - it worked,
> and the
On Tue, Dec 03, 2013 at 01:55:31PM +0100, Rafael Knuth wrote:
> Hej there,
>
> I am writing a little throw away program in order to better understand
> how I can loop through a variable and a list at the same time.
I'm afraid you may be slightly confused as to what is going on with
for-loops in
> We've already established that you've an "off by one" error in the year, but
> let's do a closer analysis of your code and mine.
Ok, got it - thank you for the clarification Mark.
No more questions for today, I learned a lot - thank you all!
:-)
All the best,
Raf
On 03/12/2013 15:03, Rafael Knuth wrote:
Hej there,
That's very poor coding, if you're given a function that does exactly what
you want, why rewrite it and worse still, get it wrong?
I don't quite understand. I took that advice, tried it - it worked,
and then I figured out there's also anothe
> for x, country in zip ( range (2009,2014), PopularCountries):
> print (x, country)
>
> And yes, Rafael, you can zip together any number of iterators this way.
>
> --
> DaveA
Thanks Dave. Got it!
Raf
___
Tutor maillist - Tutor@python.org
To unsu
On Tue, 03 Dec 2013 13:23:21 +, Mark Lawrence
wrote:
On 03/12/2013 13:11, Dave Angel wrote:
> On Tue, 3 Dec 2013 13:55:31 +0100, Rafael Knuth
>> PopularCountries = ["Brazil", "China", "France", "India",
"Vietnam"]
> You can zip two iterators together and iterate through the
resultant
Hej there,
> That's very poor coding, if you're given a function that does exactly what
> you want, why rewrite it and worse still, get it wrong?
I don't quite understand. I took that advice, tried it - it worked,
and then I figured out there's also another way to get there.
The output from the "
On 03/12/2013 14:11, Rafael Knuth wrote:
Hej there,
Loop around your list using the enumerate builtin function and an
appropriate value for start, see
http://docs.python.org/3/library/functions.html#enumerate
thanks! That hint was very helpful, and I rewrote the program as
follows (I learned
Hej there,
> Loop around your list using the enumerate builtin function and an
> appropriate value for start, see
> http://docs.python.org/3/library/functions.html#enumerate
thanks! That hint was very helpful, and I rewrote the program as
follows (I learned how to enumerate just yesterday and I f
On 03/12/2013 13:11, Dave Angel wrote:
On Tue, 3 Dec 2013 13:55:31 +0100, Rafael Knuth
wrote:
for x in range(2009, 2014):
PopularCountries = ["Brazil", "China", "France", "India", "Vietnam"]
You can zip two iterators together and iterate through the resultant
iterable of tuples.
for x, cou
On 03/12/2013 12:55, Rafael Knuth wrote:
Hej there,
I am writing a little throw away program in order to better understand
how I can loop through a variable and a list at the same time. Here's
what the program does and how it looks like: It counts the number of
backpackers (assuming a growth rat
On Tue, 3 Dec 2013 13:55:31 +0100, Rafael Knuth
wrote:
for x in range(2009, 2014):
PopularCountries = ["Brazil", "China", "France", "India", "Vietnam"]
You can zip two iterators together and iterate through the resultant
iterable of tuples.
for x, country in zip (range (2009, 2014)):
Hej there,
I am writing a little throw away program in order to better understand
how I can loop through a variable and a list at the same time. Here's
what the program does and how it looks like: It counts the number of
backpackers (assuming a growth rate of 15 % year on year) over the
last five
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:
>
20 matches
Mail list logo