Skip to content

Latest commit

 

History

History
39 lines (21 loc) · 607 Bytes

Square_Every_Digit.md

File metadata and controls

39 lines (21 loc) · 607 Bytes

CodeWars Python Solutions


Square Every Digit

Definition

Welcome. In this kata, you are asked to square every digit of a number.

For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1.

Note: The function accepts an integer and returns an integer


Given Code

def square_digits(num):
    pass

Solution

def square_digits(num):
    return int("".join([str(int(n)**2) for n in str(num)]))

See on CodeWars.com