Skip to content

Instantly share code, notes, and snippets.

@Prajwalprakash3722
Created May 11, 2021 16:20
Show Gist options
  • Save Prajwalprakash3722/2ad0326320de525719ce7da520b5ed0e to your computer and use it in GitHub Desktop.
Save Prajwalprakash3722/2ad0326320de525719ce7da520b5ed0e to your computer and use it in GitHub Desktop.
Credit card validation
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