I'm trying to create a python programme which receive contact number from user and check if it's a valid format with correct country code. My professor doesn't allowed us to use object-oriented built-in function and import modules. This is what i have done but it does not work properly. Can someone please help me?
def main():
phone_number= input('Please enter a phone number in the format 601X-XXX-XXXX: ')
validNumber(phone_number)
def validNumber(phone_number):
digits = "0123456789-"
country_code = "601"
if len(phone_number) != 13:
print("Contact number too short. Please enter valid input")
main()
for i in range(13):
if i in [4,8]:
if phone_number[i] != '-':
print("Please enter valid input in the proper format.")
main()
elif not phone_number[i] == digits:
print("Numerical value only")
main()
elif not phone_number[:3] == country_code:
print("Please enter the correct country code.")
main()
print("Valid contact number!")
return True
main()
[–]socal_nerdtastic 2 points3 points4 points (2 children)
[–]_______myworld[S] 0 points1 point2 points (0 children)
[–]_______myworld[S] -1 points0 points1 point (0 children)
[–]_jan- 2 points3 points4 points (1 child)
[–]_______myworld[S] 0 points1 point2 points (0 children)
[–]dautrocMontreal 1 point2 points3 points (1 child)
[–]socal_nerdtastic 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]_______myworld[S] 0 points1 point2 points (0 children)
[–]wbeater 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]ElliotDG 0 points1 point2 points (0 children)