+ 1
i solve this problem by this way, do u have another idea?
You are given a number input, and need to check if it is a valid phone number. A valid phone number has exactly 8 digits and starts with 1, 8 or 9. Output "Valid" if the number is valid and "Invalid", if it is not. Sample Input 81239870 Sample Output Valid https://code.sololearn.com/ccSN3655lODv/?ref=app
4 Answers
+ 4
the task can also be done without using regex:
inp = input()
if len(inp) == 8 and inp.isdigit() and inp[0] in "189":
print("Valid")
else:
print("Invalid")
+ 2
TheWhÂĄteCat đ§đŹ it said give me a number input, if saif give me a input my programme be different
+ 2
Lothar thank you, đ»
+ 1
karimireza77 , your pattern is not good, it only checks the beginning of the number. If you test it with "1qqqqqqq" it will print "Valid", which obviously is not true.