Q. Write a program that prompts for a phone number of 10 digit and two dashes , with dashes after the area code and the next three number .
Display if the phone number enter is valid format or not and display if the phone number is valid or not.
You can understand by Watching video :-
Answer
num = input("Enter your Phone number :- ") if len(num)== 12 : if num[3]== "-" : if num[4:7].isdigit() : if num [7]== "-": if num[ 8 : 13 ].isdigit() : if num[ : 3 ].isdigit() : print("It is valid number ") else : print("It is not valid number ") else : print("It is not valid number ") else : print("It is not valid number ") else : print("It is not valid number ") else : print("It is not valid number ") else : print("It is not valid number ")
Output :-
Enter your Phone number :- 017-555-1212
It is valid number
>>>
Enter your Phone number :- 654-54633-513
It is not valid number
>>>
Enter your Phone number :- 313-456-3113
It is valid number
>>>
Enter your Phone number :- 56-5643-25423
It is not valid number
>>>
Enter your Phone number :- 46-3113-55313
It is not valid number
>>>
good
ReplyDeleteThank you : )
DeleteExtremely helpful!!
ReplyDeleteWelcome : )
Deleteआपका बहुत बहुत धन्यावाद 🙏🏻🙏🏻
ReplyDeleteWelcome : )
DeleteNice
ReplyDeleteThankyou.
Deleteawesome
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )