python - Validate input 16-digit credit card number -


i need validate input string should contain 16 integer digits, no more, no less. how can it?

check length using len. use str.isdigit check string contain digits.

>>> valid = '1234567890123456' >>> invalid = '1848934798237489324324' >>> len(valid) == 16 , valid.isdigit() true >>> len(invalid) == 16 , invalid.isdigit() false 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -