Answer to Question #269088 in Python for ASHim

Question #269088

write a program that takes string as an input and return the product of all individual digit present in string ,return 0


1
Expert's answer
2021-11-20T06:41:41-0500


SOLUTION TO THE ABOVE QUESTION


SOLUTION CODE


#propmt the user to enter a string containing digits
my_digit_string = input("\nEnter a string containing digits: ")

#find the length of the string
string_length = len(my_digit_string)

#declare a variable to store the product of the digits in the string
string_didits_product = 1

for i in range(0,string_length):
    if my_digit_string[i].isdigit():
        string_didits_product = string_didits_product * int(my_digit_string[i])

##print the product of digits in our string
print("\nThe product of dits in our string = "+str(string_didits_product))


SAMPLE PROGRAM OUTPUT






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS