0

Phone number

how to finf information about a phone number

26th Oct 2020, 2:50 AM
swafrikenya
2 odpowiedzi
0
Use can use following example reference : import re #Function to check if input is valid mobile number def is_valid_mobile_number(mobile_number): pattern = re.compile("^[0-9]{10,10}
quot;) if (pattern.match(mobile_number)): return True else: return False #Function to find information about the mobile number def find_information_about_mobile_number(mobile_number): if(is_valid_mobile_number(mobile_number)): #Finding the operator first_three_digits = mobile_number[:3] if(first_three_digits == '984'): print("Operator: Ncell") elif(first_three_digits == '985'): print("Operator: NTC") elif(first_three_digits == '986'): print("Operator: SmartCell") else: print("Operator: Unknown") #Finding the location if(first_three_digits == '984' or first_three_digits == '985'): fourth_digit = mobile_number[3] if(fourth_digit == '0'): print("Location: Kathmandu Valley") elif(fourth_digit == '1'): print("Location: Outside Kathmandu Valley") else: print("Location: Unknown")
11th Jan 2023, 9:57 PM
Aditya Dixit
0
continue from previous code: elif(first_three_digits == '986'):fourth_digit = mobile_number[3] if(fourth_digit == '0'): print("Location: Kathmandu Valley") elif(fourth_digit == '1' or fourth_digit == '2' or fourth_digit == '3' or fourth_digit == '4' or fourth_digit == '5' or fourth_digit == '6'): print("Location: Outside Kathmandu Valley") else: print("Location: Unknown") else: print("Location: Unknown") else: print("Invalid Mobile Number!") #Input mobile number mobile_number = input("Enter the mobile number: ") #Finding information about the mobile number find_information_about_mobile_number(mobile_number)
11th Jan 2023, 10:02 PM
Aditya Dixit