{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "example\n", "w3resource\n", "github\n", "stackoverflow\n" ] } ], "source": [ "# Write a Python program to remove the parenthesis area in a string.\n", "# \n", "# Input\n", "# [\"example (.com)\", \"w3resource\", \"github (.com)\", \"stackoverflow (.com)\"]\n", "# \n", "# Output\n", "# example \n", "# w3resource \n", "# github \n", "# stackoverflow\n", "\n", "import re\n", "items = [\"example (.com)\", \"w3resource\", \"github (.com)\", \"stackoverflow (.com)\"]\n", "for item in items:\n", " print(re.sub(r\" ?\\([^)]+\\)\", \"\", item))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }