Search code examples
python

How to return the fractional part of a number?


How can I get the fractional part of a number?

For example, I have a list of floats num = [12.73, 9.45] and want to get only the numbers after the decimal point, 73 and 45 in this case. How do I go about doing this?


Solution

  • num = [12.73, 9.45];
    result = [int(str(x).split('.')[1]) for x in num]
    print(result)