Created
March 21, 2020 17:39
-
-
Save johnifegwu/78aeda9bb3c58e4feae1a688ac38b7db to your computer and use it in GitHub Desktop.
Passport Number Extraction and 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 | |
#Character Classess | |
#Passport number | |
pattern = r"[A-Za-z][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" | |
while True: | |
num = "Last Name: Doe \n" | |
num += "Other names: John \n" | |
num += "DOB:22-Jan-1990 \n" | |
num += "Passport number: " + input("Enter your 9 digit passport number (eg. A01234567): ") + "\n" | |
num += "Place of Issue: Lagos, Nigeria. \n" | |
num += "Date Issued: 31-Oct-2017 \n" | |
num += "Expires: 30-Oct-2022 \n" | |
print("Your passport details are: \n") | |
print(num + "\n Searching.....\n") | |
match = re.search(pattern, num) | |
if match: | |
pNum = match.group() | |
if (len(pNum) == 9): | |
print("Marched! \n Your passport number is: {0}".format(pNum)) | |
else: | |
print("Invalid number!") | |
else: | |
print("Invalid number!") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment