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 put
print number[:-1]
but it works for variables with text(like "hello) but not with numbers. With numbers I get this error:
TypeError: 'int' object is not subscriptable
I am trying to see if there's a better way to deal with numbers this way. I know a solution is to convert to a string and then do the above command but I'm trying to see if there's another way I have missed.
Thanks so much in advance...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…