Posts

Showing posts with the label decimal

while/try/except decimal TypeError not working

while/try/except decimal TypeError not working I thought I could finally get some use out of the while/try/except loop, but I am encountering a problem. My task is to have the computer request numbers from a user until '0' is entered. After this, the numbers entered will be added. My problem is that the Except part isn't catching non-numeric entries. If a non-numeric entry is entered, I get a regular error message that stops the program. Here is what happens when I enter 3 numbers and the 4th entry is 'm': on win32 Type "copyright", "credits" or "license()" for more information. >>> RESTART: C:/Users/Username/Documents/CISPROG1/Homework 5/Homework5.1.SumGenerator.py Enter 1st element (or type '0' to finish). 1 Enter 2nd element (or type '0' to finish). 2 Enter 3rd element (or type '0' to finish). 3 Enter 4th element (or type '0' to finish). m Traceback (most recent call last): File "C:/...