Himel-Rana

Ans to the q. no: 4

Apr 17th, 2021
673
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Bangladesh Country code: +880
  2. # India Country code: +91
  3. # Pakistan Country code: +92
  4. # Usa Country code: +1
  5. # UK country code +44
  6.  
  7. # number to country
  8. def get_country(number):
  9.     if number[0:4] == '+880' or number[0:3] == '880':
  10.         return "Bangladesh"
  11.     elif number[0:3] == '+91' or number[0:2] == '91':
  12.         return "India"
  13.     elif number[0:3] == '+92' or number[0:2] == '92':
  14.         return "Pakistan"
  15.     elif number[0:2] == '+1' or number[0:1] == '1':
  16.         return "United States (US)"
  17.     elif number[0:3] == '+44' or number[0:2] == '44':
  18.         return "United Kingdom (UK)"
  19.     else:
  20.         return "Unknown Country"
  21.  
  22.  
  23. phone_numbers = open('phone-numbers.txt', 'r')
  24. Lines = phone_numbers.readlines()
  25.  
  26. count = 0
  27. for line in Lines:
  28.     count += 1
  29.     country = get_country(line.strip())
  30.     print("Phone Number: {} country: {}".format(line.strip(), country))
  31.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×