Re: Help printing the integers of a longer number

2013-03-28 Thread Chris Angelico
On Fri, Mar 29, 2013 at 4:11 AM, Jussi Piitulainen wrote: > Jussi Piitulainen writes: > >> khao...@gmail.com writes: >> >> > I want to print the individual numbers of a large number using >> > division and modulus division. >> > >> > For example: >> > >> > Enter a positive integer: 54321 >> > 5 >>

Re: Help printing the integers of a longer number

2013-03-28 Thread Chris Angelico
On Fri, Mar 29, 2013 at 4:03 AM, Jussi Piitulainen wrote: > def print_digits(num): >left, last = divmod(num, 10) >if left < 0: print the digits of left >print(last) > > How do you print the digits of left? With print_digits. Why does it > work? Because you only call print_digits again

Re: Help printing the integers of a longer number

2013-03-28 Thread Jussi Piitulainen
Jussi Piitulainen writes: > khao...@gmail.com writes: > > > I want to print the individual numbers of a large number using > > division and modulus division. > > > > For example: > > > > Enter a positive integer: 54321 > > 5 > > 4 > > 3 > > 2 > > 1 > > Those numbers are called the digits of th

Re: Help printing the integers of a longer number

2013-03-28 Thread Jussi Piitulainen
khao...@gmail.com writes: > I want to print the individual numbers of a large number using > division and modulus division. > > For example: > > Enter a positive integer: 54321 > 5 > 4 > 3 > 2 > 1 Those numbers are called the digits of the large number. With divmod(54321, 10) you get both the

Re: Help printing the integers of a longer number

2013-03-28 Thread Chris Angelico
On Fri, Mar 29, 2013 at 1:39 AM, wrote: > I want to print the individual numbers of a large number using division and > modulus division. > > For example: > > Enter a positive integer: 54321 > 5 > 4 > 3 > 2 > 1 Python has two operators that can help here: // for integer division - returns the

Re: Help printing the integers of a longer number

2013-03-28 Thread Joel Goldstick
On Thu, Mar 28, 2013 at 10:39 AM, wrote: > I want to print the individual numbers of a large number using division > and modulus division. > > For example: > > Enter a positive integer: 54321 > 5 > 4 > 3 > 2 > 1 > > This looks familiar. Make the integer a string and use a for loop to iterate ove