write a program that takes string as an input and return the product of all individual digit present in string ,return 0
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
Comments
Leave a comment