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
On Tue, 3 Dec 2013 13:55:31 +0100, Rafael Knuth
rafael.kn...@gmail.com 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
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
On 03/12/2013 13:11, Dave Angel wrote:
On Tue, 3 Dec 2013 13:55:31 +0100, Rafael Knuth rafael.kn...@gmail.com
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
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
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,
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 Tue, 03 Dec 2013 13:23:21 +, Mark Lawrence
breamore...@yahoo.co.uk wrote:
On 03/12/2013 13:11, Dave Angel wrote:
On Tue, 3 Dec 2013 13:55:31 +0100, Rafael Knuth
rafael.kn...@gmail.com
PopularCountries = [Brazil, China, France, India,
Vietnam]
You can zip two iterators together and
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
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
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 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
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 then I
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, country in
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 %d backpackers worldwide
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 = 100
msg =
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
17 matches
Mail list logo