Write a Python program to delete a character from a string.

Delete a character from a string in Python. Write a Python program to delete a character from a string.

How to delete a character from a string?

The string class has a method remove that can be used to remove a character in a string.

What is deleting a character from a string?

Input: welcome
Deleting ‘l’
Output: wecome

Algorithm to delete a character from a string:

• Enter a string and the character you want to delete.
• Use the remove() function to delete the character and then join() function to join it.
• Print the new string.

Python program to delete a character in a string.

def remove(str,char):
    return "".join(c for c in str if c not in char)
print(remove("welcome to the python world","o"))

Output: Printing the string after deletion of the character.