how to get the number in the tenths place of a integer in python 1

how to get the number in the tenths place of a integer in python

def get_pos_nums(num):
    pos_nums = []
    while num != 0:
        pos_nums.append(num % 10)
        num = num // 10
    return pos_nums

Here is what the above code is Doing:
1. We are taking the number and getting the last digit of it.
2. We are appending that digit to the list.
3. We are dividing the number by 10 to get the next digit.
4. We are repeating the above steps until the number becomes 0.

Similar Posts