generated from Hsins-Learn/Learn-Note-Template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
solution.py
123 lines (93 loc) · 3.22 KB
/
solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import re
#Asking the user for the first name and checking the format
while True:
fname = input("\nPlease enter your First Name: ")
check = re.fullmatch(r"[A-Z][a-z]+", fname)
if check == None:
print("Wrong format! Please try again.")
continue
else:
break
#Asking the user for the last name and checking the format
while True:
lname = input("\nPlease enter your Last Name: ")
check = re.fullmatch(r"[A-Z][a-z]+", lname)
if check == None:
print("Wrong format! Please try again.")
continue
else:
break
#Asking the user for the date of birth and checking the format
while True:
date = input("\nPlease enter your Date of Birth (mm/dd/yyyy): ")
check = re.fullmatch(r"(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/(19[0-9][0-9]|200[01])", date)
if check == None:
print("Wrong format! Please try again.")
continue
else:
break
#Asking the user for the email address and checking the format
while True:
email = input("\nPlease enter your Email Address: ")
check = re.fullmatch(r"(\w|\.)+@[a-z]+\.[a-z]{2,4}", email)
if check == None:
print("Wrong format! Please try again.")
continue
else:
break
#Asking the user for the username and checking the format
while True:
user = input("\nPlease enter your Username: ")
check = re.fullmatch(r"\w{6,12}", user)
if check == None:
print("Wrong format! Please try again.")
continue
else:
break
#Asking the user for the password and checking the format
while True:
passw = input("\nPlease enter your Password: ")
check = re.fullmatch(r"^[a-z](?=.{7,})(?=.*[A-Z])(?=.*\d)(?=.*[$&?!%])[a-zA-Z0-9$&?!%]+$", passw)
if check == None:
print("Wrong format! Please try again.")
continue
else:
break
#Asking the user for the credit card number and checking the format
while True:
ccnum = input("\nPlease enter your Credit Card Number (no spaces): ")
check = re.fullmatch(r"^(4|5)\d{15}", ccnum)
if check == None:
print("Wrong format! Please try again.")
continue
else:
break
#Asking the user for the credit card expiration date and checking the format
while True:
ccdat = input("\nPlease enter your Credit Card Expiration Date (mm/yy): ")
check = re.fullmatch(r"(0[5-9]|1[0-2])/24|(0[1-9]|1[0-2])/(2[5-9]|[3-9][0-9])", ccdat)
if check == None:
print("Wrong format! Please try again.")
continue
else:
break
#Asking the user for the credit card verification code and checking the format
while True:
cccvc = input("\nPlease enter your Credit Card Verification Code: ")
check = re.fullmatch(r"\d{3}", cccvc)
if check == None:
print("Wrong format! Please try again.")
continue
else:
break
userinfo = ["First Name: " + fname,
"Last Name: " + lname,
"Date of birth: " + date,
"Email address: " + email,
"Username: " + user,
"Password: " + passw,
"Card number: " + ccnum,
"Expiration date: " + ccdat,
"CVC: " + cccvc]
string = "\n".join(userinfo)
print(f"This is your user account information:\n\n{string}")