If i have a string like this: asdf5493
I need the last four digits and i get it by doing this:
strVar[-4:]
Is it possible to then see if they are all numbers?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
tests if all four characters are digits. Documentation
EDIT: If your actual goal is to convert this number to an integer, the usual idiom in Python is to just try to do this, and catch the exception in case it fails: