Created
May 11, 2021 16:20
-
-
Save Prajwalprakash3722/2ad0326320de525719ce7da520b5ed0e to your computer and use it in GitHub Desktop.
Credit card validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def validation(): | |
t = int(input().strip()) | |
for _ in range(t): | |
num = "".join(input()) | |
if (re.match(r'^[456]', num) and | |
(re.match(r'([\d]{4}-){3}[\d]{4}$', num) or | |
re.match(r'[\d]{16}', num)) and | |
not re.search(r'(\d)\1{3,}', num.replace("-", ""))): | |
print("Valid") | |
else: | |
print("Invalid") | |
if __name__ == "__main__": | |
validation() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment