Q. Write a function deleteChar() which takes two parameters one is a string and other is a character. The function should create a new string after deleting all occurrences of the character from the string and return the new string.


Answer :-


def deleteChar( string , char ):
    newstr = ""
    for i in string :
        if char != i :
            newstr += i
    return newstr

string = input("Enter a sting :-")
char = input( "Enter a Character :-" )
print("New String :-", deleteChar( string , char ) )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post