Skip to content

Commit d2f69d6

Browse files
committed
Created using Colab
1 parent 3d66fb8 commit d2f69d6

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

Untitled0.ipynb

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"nbformat": 4,
3+
"nbformat_minor": 0,
4+
"metadata": {
5+
"colab": {
6+
"provenance": [],
7+
"authorship_tag": "ABX9TyPugviIJHWtsAokvuohWccx",
8+
"include_colab_link": true
9+
},
10+
"kernelspec": {
11+
"name": "python3",
12+
"display_name": "Python 3"
13+
},
14+
"language_info": {
15+
"name": "python"
16+
}
17+
},
18+
"cells": [
19+
{
20+
"cell_type": "markdown",
21+
"metadata": {
22+
"id": "view-in-github",
23+
"colab_type": "text"
24+
},
25+
"source": [
26+
"<a href=\"https://colab.research.google.com/github/Vidushee23/Basic-Python-Programs/blob/main/Untitled0.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": null,
32+
"metadata": {
33+
"id": "m2WrU8ZkZZNx"
34+
},
35+
"outputs": [],
36+
"source": [
37+
"def is_valid_indian_phone(number):\n",
38+
" # Remove any spaces or hyphens\n",
39+
" number = number.replace(' ', '').replace('-', '')\n",
40+
"\n",
41+
" # Check for +91 or 91 prefix and remove if present\n",
42+
" if number.startswith('+91'):\n",
43+
" number = number[3:]\n",
44+
" elif number.startswith('91'):\n",
45+
" number = number[2:]\n",
46+
"\n",
47+
" # Check if the number is 10 digits long and starts with 6, 7, 8, or 9\n",
48+
" if len(number) == 10 and number[0] in '6789':\n",
49+
" return True\n",
50+
"\n",
51+
" return False\n",
52+
"\n",
53+
"valid_count = 0\n",
54+
"\n",
55+
"for patient in data:\n",
56+
" phone = patient['phoneNumber']\n",
57+
" is_valid = is_valid_indian_phone(phone)\n",
58+
" patient['isValidMobile'] = is_valid\n",
59+
" if is_valid:\n",
60+
" valid_count += 1\n",
61+
"\n",
62+
"print(f\"Number of valid phone numbers: {valid_count}\")\n"
63+
]
64+
},
65+
{
66+
"cell_type": "code",
67+
"source": [],
68+
"metadata": {
69+
"id": "xCl63LnwZrJ7"
70+
},
71+
"execution_count": null,
72+
"outputs": []
73+
}
74+
]
75+
}

0 commit comments

Comments
 (0)