[Tutor] (no subject)

Steven D'Aprano steve at pearwood.info
Sun Apr 7 02:02:44 CEST 2013


On 07/04/13 09:10, Soliman, Yasmin wrote:
> How can I fix this loop so that it multiplies the two intergers and if user types in 'quit' for either number it stops? if not it keeps going.


How would you solve this problem in real life? Right down the steps you would do, as if you were explaining it to a child, or an idiot. Remember that computers are dumber than any child, so make the steps as simple as you can.

* Ask the user for a value
* if the first value is "Quit", then stop
* Ask the user for a second value
* If the second value is "Quit", then stop
* Convert the first value to an int (instead of a string)
* Convert the second value to an int (instead of a string)
* Multiply the two ints

Now put that into Python code. Get it working. If you have *specific* questions, please ask, but this question is so broad and general that you're basically asking us to do everything.

Once it works, then put it inside a loop.

The secret to programming is to break tasks up into smaller tasks, smaller and simpler, until they are so small and simple that even a computer can do them. Then put the pieces together, in the right order.


P.S. Please use a sensible subject line.


-- 
Steven


More information about the Tutor mailing list