Q:

Write a Python program to delete all occurrences of a specified character in a given string.

0

Write a Python program to delete all occurrences of a specified character in a given string.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def delete_all_occurrences(str1, ch):
     result = str1.replace(ch, "")
     return(result)

str_text = "Delete all occurrences of a specified character in a given string"
print("Original string:")
print(str_text)
print("\nModified string:")
ch='a'
print(delete_all_occurrences(str_text, ch))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now