[Tutor] Help on Python Looping Please

2011-02-24 Thread pyhx0r
Dear All, I’m new in programming and I’m studying Python now. I use Python 3.1.2 and learn from Dive Into Python 3 book (Mark Pilgrim, Thank you very much for him). I’ve learned list, tuple, set, dictionary and little bit about looping. I’m so confused about looping in first Python Program in

Re: [Tutor] Help on Python Looping Please

2011-02-24 Thread Walter Prins
On 24 February 2011 14:52, pyhx0r pyh...@gmail.com wrote: *Why do in my code, it loops to all values and not in Mark Pilgrim’s code? * Because in Mark's code the loop is terminated by the return statement (contained in the utility function approximate_size().) In your code you've removed the

Re: [Tutor] Help on Python Looping Please

2011-02-24 Thread Dave Angel
On 01/-10/-28163 02:59 PM, pyhx0r wrote: Dear All, snip multiple = 1024 if a_kilobyte_is_1024_bytes else 1000 for suffix in SUFFIXES[multiple]: size /= multiple if size multiple: return '{0:.1f} {1}'.format(size, suffix) snip I’ve shorted the code

Re: [Tutor] Help on Python Looping Please

2011-02-24 Thread pyhx0r
Dear All, Thank you for your advise, it's helpful for me. NB: To DaveA, It was copy-paste from my notepad so the indentation went wrong :( +---+--+---+ | py | h | x0r | +---+--+---+ ■ 1 3 0 E2 C 9 ■ ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Help on Python Looping Please

2011-02-24 Thread Walter Prins
On 24 February 2011 16:22, Dave Angel da...@ieee.org wrote: (Is there a reason you double-spaced all that code? It makes it very hard to read, and quite difficult to quote, since I had to delete every other line.) For what it's worth the code came out perfectly fine on my email reader

Re: [Tutor] Help on Python Looping Please

2011-02-24 Thread Dave Angel
On 02/24/2011 11:55 AM, Walter Prins wrote: On 24 February 2011 16:22, Dave Angelda...@ieee.org wrote: (Is there a reason you double-spaced all that code? It makes it very hard to read, and quite difficult to quote, since I had to delete every other line.) For what it's worth the code