Ad
  • Custom User Avatar

    I forgot the .join builtin. To use list comprehension was way good! I need to learn it.

  • Custom User Avatar

    You're not supposed to paste solutions here.

  • Custom User Avatar

    You're not supposed to paste solutions here.

  • Custom User Avatar

    def digital_root(n):

    sum = 0
    temp = n #temparory variable to store n
    while temp > 9:
        for i in str(temp): #convert the integer to a string to iterate through
            sum += int(i)
        temp = sum
        #change the sum back to 0 for further iterations
        sum = 0
    
    return temp
    

    This was my solution to the digital root problem, this is not the most efficient solution. Can anyone post more efficient solutions to this problem?

  • Custom User Avatar

    def create_phone_number(n):

    if len(n) == 10:
        phone_number = ''.join(str(i) for i in n)
        newPhone = "(" + phone_number[0:3] + ")" + ' ' + phone_number[3:6] + '-' + phone_number[6:12]
    return newPhone
    

    This was a solution to the phone number problem, but I believe there are so many more efficient solutions, help me improvise this solution.

  • Custom User Avatar

    Please don't post solutions in kata's Discourse. Use Solutions section to discuss it. Even there, use spoiler flag when appropiate.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution