I have a string:
i = '12345678901'
How to check (with python) if one before last digit in a string is even or odd ?
In a string above I want function to return or print “even”.
I found some examples but they are in C and i don’t know how to use it in Python
There are (at least) two ways of doing this:
Method 1:
Get the character at index -2 and intify it and check its modulus with 2
Method 2:
intify
i, and divide by 10 and mod by 10 to get at the second last digit and nod by 2 get determine if it’s even or odd