how to solve Convert a Number to a String! 8 kyu codewars challenge in python

We need a function that can transform a number (integer) into a string.

What ways of achieving this do you know?

Examples (input --> output):

123  --> "123"

999  --> "999"

-100 --> "-100"


solution:

1. use str() method e.g return str(argument)


#code

def number_to_string(num):

    stringnum = str(num)

    return stringnum


---------------------or-----------

def num_to_string(num):

    return str(num) 





Comments

Popular Posts