Re: [Tutor] blank space after a number

2010-12-28 Thread bob gailer
On 12/28/2010 8:09 PM, bob gailer wrote: Now that I understand what you want - for b in range(120): print '%0*i' % (max(2,int(math.log10(b))), b) Sorry forgot to add import math -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tuto

Re: [Tutor] blank space after a number

2010-12-28 Thread Alan Gauld
"Enih Gilead" wrote a, b = 0, 1 while b < 10: print '%i%i' % (a,b) + ',', b = b+1 If you are using string formatting it's best to get the format string to do as much of the work as possible. In this case forget about 'a' and just insert the zero into the string, and similarly don'

Re: [Tutor] blank space after a number

2010-12-28 Thread bob gailer
Now that I understand what you want - for b in range(120): print '%0*i' % (max(2,int(math.log10(b))), b) -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pyth

Re: [Tutor] blank space after a number

2010-12-28 Thread Noah Hall
I'll just add there's a better way to do both of the examples you've done there - > > a, b = 0, 1 > > while b < 10: > >print '%i%i' % (a,b) + ',', > >b = b+1 An easier way of doing this is to instead do the following, including the a (although not needed, as simply using 0 would work) -

Re: [Tutor] blank space after a number

2010-12-28 Thread Enih Gilead
Thanks a lot, Hugo Yoshi! As a beginner in Python, I do my best to satisfy my curiosity about some features in the language; and, this one was the most difficult among my "projects"! :c) Best regards, Enih Gil'ead # Formatting numbers from '01,' to '100' # Many thanks to Bob Gailer and to

Re: [Tutor] blank space after a number

2010-12-28 Thread bob gailer
On 12/28/2010 2:36 PM, Alan Gauld wrote: "Enih Gilead" wrote Just as an example, the 'a' that is made = to '0', when printed, it comes with a blank space after... a, b = 0, 1 while b < 10: print a, b, a, b = a, b + 1 ... do you think is there any reasonable way to transform the '0'

Re: [Tutor] blank space after a number

2010-12-28 Thread Alan Gauld
"Enih Gilead" wrote Just as an example, the 'a' that is made = to '0', when printed, it comes with a blank space after... a, b = 0, 1 while b < 10: print a, b, a, b = a, b + 1 ... do you think is there any reasonable way to transform the '0' number into string and then back to nume

Re: [Tutor] blank space after a number

2010-12-28 Thread bob gailer
On 12/28/2010 8:54 AM, Enih Gilead wrote: Hi, Abrahamsen! Would you mind tell me a way to eliminate the blank space in front of "a" [int number] ? Just as an example, the 'a' that is made = to '0', when printed, it comes with a blank space after... a, b = 0, 1 while b < 10: print a, b,

Re: [Tutor] blank space after a number

2010-12-28 Thread Hugo Arts
On Tue, Dec 28, 2010 at 2:54 PM, Enih Gilead wrote: > Hi, Abrahamsen! > > Would you mind tell me a way to eliminate the blank space in front of "a" > [int number] ? > Just as an example, the 'a' that is made = to '0', when printed, it comes > with a blank space after... > > a, b = 0, 1 > while b <

[Tutor] blank space after a number

2010-12-28 Thread Enih Gilead
Hi, Abrahamsen! Would you mind tell me a way to eliminate the blank space in front of "a" [int number] ? Just as an example, the 'a' that is made = to '0', when printed, it comes with a blank space after... a, b = 0, 1 while b < 10: print a, b, a, b = a, b + 1 ... do you think is the