{"id":12851,"date":"2021-09-30T12:30:41","date_gmt":"2021-09-30T07:00:41","guid":{"rendered":"https:\/\/python-programs.com\/?p=12851"},"modified":"2021-11-22T18:34:38","modified_gmt":"2021-11-22T13:04:38","slug":"python-program-to-remove-a-string-from-a-list-of-strings","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-remove-a-string-from-a-list-of-strings\/","title":{"rendered":"Python Program to Remove a String from a List of Strings"},"content":{"rendered":"

Given a list of strings and another string the task is to remove the given string from the given list of strings.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given list of strings =['hello', 'this', 'is', 'btechgeeks', 'python', 'coding', 'platform']\r\nGiven string ='python'<\/pre>\n

Output:<\/strong><\/p>\n

The given list of strings before removing the string [ python ] is ['hello', 'this', 'is', 'btechgeeks', 'python', 'coding',\r\n 'platform']\r\nThe given list of strings after removing the string [ python ] is ['hello', 'this', 'is', 'btechgeeks', 'coding', 'platform']<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given list of strings =['hello', 'food', 'morning', 'this', 'is', 'btechgeeks', 'online', 'coding', 'platform', \r\n                                    'for', 'geeks', 'online']\r\nGiven string ='geeks'<\/pre>\n

Output:<\/strong><\/p>\n

The given list of strings before removing the string [ geeks ] is ['hello', 'food', 'morning', 'this', 'is', 'btechgeeks', \r\n                                                                                                      'online', 'coding', 'platform', 'for', 'geeks', 'online']\r\nThe given list of strings after removing the string [ geeks ] is ['hello', 'food', 'morning', 'this', 'is', 'btechgeeks',\r\n                                                                                                  'online', 'coding', 'platform', 'for', 'online']<\/pre>\n

Program to Remove a String from a List of Strings in Python<\/h2>\n

Below are the ways to remove the given string from the given list of strings.<\/p>\n