Python – substr

PHPpythonsubstr

I need to be able to get the last digit of a number.

i.e., I need 2 to be returned from: 12.

Like this in PHP: $minute = substr(date('i'), -1) but I need this in Python.

Any ideas

Best Answer

last_digit = str(number)[-1]