Is there a way to get the last digit of a number. I am trying to find variables that end with \"1\" like 1,11,21,31,41,etc..
If I use a text variable I can simply pu
Lostsoul, this should work:
number = int(10)
#The variable number can also be a float or double, and I think it should still work.
lastDigit = int(repr(number)[-1])
#This gives the last digit of the variable "number."
if lastDigit == 1 :
print("The number ends in 1!")
Instead of the print statement at the end, you can add code to do what you need to with numbers ending in 1.
Hope it helped!