Re: [Tutor] Squaring every digit in number

2015-11-21 Thread Peter Otten
Aadesh Shrestha wrote: > I am currently taking challenges on codewars. > Problem: Square Every Digit > > is there a better solution than this which requires less code? > > def square_digits(num): > arr = [] > list = [] > while(num !=0): > temp = num%10 > num = num /1

Re: [Tutor] Squaring every digit in number

2015-11-21 Thread Nathan Hilterbrand
On 11/21/2015 7:05 AM, Aadesh Shrestha wrote: I am currently taking challenges on codewars. Problem: Square Every Digit is there a better solution than this which requires less code? def square_digits(num): arr = [] list = [] while(num !=0): temp = num%10 num

Re: [Tutor] Squaring every digit in number

2015-11-21 Thread Alan Gauld
On 21/11/15 12:05, Aadesh Shrestha wrote: is there a better solution than this which requires less code? Yes, several. But less lines of code is not necessarily better. it might take more memory, or run slower. So better is a relative term and you always need to think about what you mean by b

Re: [Tutor] Squaring every digit in number

2015-11-21 Thread Joel Goldstick
On Sat, Nov 21, 2015 at 10:06 AM, Laura Creighton wrote: > In a message of Sat, 21 Nov 2015 17:50:49 +0545, Aadesh Shrestha writes: > >I am currently taking challenges on codewars. > >Problem: Square Every Digit > > > >is there a better solution than this which requires less code? > > > >def squa

Re: [Tutor] Squaring every digit in number

2015-11-21 Thread Laura Creighton
In a message of Sat, 21 Nov 2015 17:50:49 +0545, Aadesh Shrestha writes: >I am currently taking challenges on codewars. >Problem: Square Every Digit > >is there a better solution than this which requires less code? > >def square_digits(num): >arr = [] >list = [] >while(num !=0): >

[Tutor] Squaring every digit in number

2015-11-21 Thread Aadesh Shrestha
I am currently taking challenges on codewars. Problem: Square Every Digit is there a better solution than this which requires less code? def square_digits(num): arr = [] list = [] while(num !=0): temp = num%10 num = num /10 arr.insert(0, temp) for i in arr