Q. Input a string having some digits. Write a function to return the sum of digits present in this string.


Answer :-


def path( string ):
    digit = 0
    for i in string :
        if i.isdigit():
            digit += int( i )
    return digit

string = input("Enter a String :-")
print("Sum of Digit :-", path(string) )

4 Comments

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

Post a Comment

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

Previous Post Next Post