In my programming class, we need to write a program where the user is prompted for a value. Once that value is provided, the program is supposed to multiply its digits. For example: if the user typed 1234, it would multiply 1*2*3*4 and give the answer. I'm not sure how to multiply the digits and my teacher mentioned using a while loop.

9 Years
Discussion Span
Last Post by Stefano Mtangoo

This problem is really simple:
1. You can loop python strings like anyway other container.
2. You can convert a digit string ("1") to an integer (1) using int()

I'm not even going to tell you how to do the rest. Go ahead and prove that you aren't lazy.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.