From d2f69d6c5f03fefe450cf60f68794c9cce272134 Mon Sep 17 00:00:00 2001 From: Vidushee23 <117992509+Vidushee23@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:42:24 +0530 Subject: [PATCH] Created using Colab --- Untitled0.ipynb | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Untitled0.ipynb diff --git a/Untitled0.ipynb b/Untitled0.ipynb new file mode 100644 index 00000000..adffac3d --- /dev/null +++ b/Untitled0.ipynb @@ -0,0 +1,75 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyPugviIJHWtsAokvuohWccx", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "m2WrU8ZkZZNx" + }, + "outputs": [], + "source": [ + "def is_valid_indian_phone(number):\n", + " # Remove any spaces or hyphens\n", + " number = number.replace(' ', '').replace('-', '')\n", + "\n", + " # Check for +91 or 91 prefix and remove if present\n", + " if number.startswith('+91'):\n", + " number = number[3:]\n", + " elif number.startswith('91'):\n", + " number = number[2:]\n", + "\n", + " # Check if the number is 10 digits long and starts with 6, 7, 8, or 9\n", + " if len(number) == 10 and number[0] in '6789':\n", + " return True\n", + "\n", + " return False\n", + "\n", + "valid_count = 0\n", + "\n", + "for patient in data:\n", + " phone = patient['phoneNumber']\n", + " is_valid = is_valid_indian_phone(phone)\n", + " patient['isValidMobile'] = is_valid\n", + " if is_valid:\n", + " valid_count += 1\n", + "\n", + "print(f\"Number of valid phone numbers: {valid_count}\")\n" + ] + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "xCl63LnwZrJ7" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file