{ "cells": [ { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "import phonenumbers\n", "from phonenumbers import carrier" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['+14322228152',\n", " '+13254509104',\n", " '+14323012230',\n", " '+14326314847',\n", " '+14326311606',\n", " '+14326311503',\n", " '+14326409671']" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "numbers = \"+14322228152,+13254509104,+14323012230,+14326314847,+14326311606,+14326311503,+14326409671\"\n", "numbers = numbers.split(\",\")\n", "numbers" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Country Code: 1 National Number: 4322228152\n", "Is Possible: True\n", "Is Valid: True\n", "Country Code: 1 National Number: 3254509104\n", "Is Possible: True\n", "Is Valid: True\n", "Country Code: 1 National Number: 4323012230\n", "Is Possible: True\n", "Is Valid: True\n", "Country Code: 1 National Number: 4326314847\n", "Is Possible: True\n", "Is Valid: True\n", "Country Code: 1 National Number: 4326311606\n", "Is Possible: True\n", "Is Valid: True\n", "Country Code: 1 National Number: 4326311503\n", "Is Possible: True\n", "Is Valid: True\n", "Country Code: 1 National Number: 4326409671\n", "Is Possible: True\n", "Is Valid: True\n" ] } ], "source": [ "for number in numbers:\n", " n = phonenumbers.parse(number, None)\n", " print(n)\n", " print(f\"Is Possible: {phonenumbers.is_possible_number(n)}\")\n", " print(f\"Is Valid: {phonenumbers.is_valid_number(n)}\")\n", " #print(f\"Carrier: {carrier.name_for_number(n,\"en\")}\")\n" ] } ], "metadata": { "kernelspec": { "display_name": "phoneValidator", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.0" } }, "nbformat": 4, "nbformat_minor": 2 }