import phonenumbers from phonenumbers import geocoder, carrier, timezone def track_phone_location(phone_number): try: # Parse the phone number parsed_number = phonenumbers.parse(phone_number) # Get location information country = geocoder.description_for_number(parsed_number, "en") # Get carrier information service_provider = carrier.name_for_number(parsed_number, "en") # Get timezone information time_zones = timezone.time_zones_for_number(parsed_number) # Check if the number is valid is_valid = phonenumbers.is_valid_number(parsed_number) return { "phone_number": phone_number, "country": country, "service_provider": service_provider, "time_zones": list(time_zones), "is_valid": is_valid } except Exception as e: return { "error": str(e), "phone_number": phone_number } def main(): while True: print("\nPhone Number Location Tracker") print("----------------------------") phone_number = input("Enter phone number (with country code, e.g., +1234567890) or 'q' to quit: ") if phone_number.lower() == 'q': print("Goodbye!") break result = track_phone_location(phone_number) if "error" in result: print(f"\nError: {result['error']}") else: print("\nResults:") print(f"Phone Number: {result['phone_number']}") print(f"Country: {result['country']}") print(f"Service Provider: {result['service_provider']}") print(f"Time Zones: {', '.join(result['time_zones'])}") print(f"Valid Number: {'Yes' if result['is_valid'] else 'No'}") if __name__ == "__main__": main()