changes value to type error
authorKaty Huff <katyhuff@gmail.com>
Sun, 13 Jan 2013 17:43:15 +0000 (11:43 -0600)
committerW. Trevor King <wking@tremily.us>
Fri, 1 Nov 2013 04:00:49 +0000 (21:00 -0700)
python/testing/Readme.md
python/testing/mean.py

index 12bb6c2b628a0868f20136a7b2b629c024184c1d..30afea66c240f17214aa46c2b0c60ff9f253551c 100644 (file)
@@ -72,8 +72,8 @@ def mean(numlist):
     try:
         total = sum(numlist)
         length = len(numlist)
-    except ValueError:
-        print "The number list was not a list of numbers."
+    except TypeError:
+        raise TypeError("The number list was not a list of numbers.")
     except:
         print "There was a problem evaluating the number list."
     return total/length
@@ -87,8 +87,8 @@ def mean(numlist):
     try:
         total = sum(numlist)
         length = len(numlist)
-    except ValueError:
-        print "The number list was not a list of numbers."
+    except TypeError:
+        raise TypeError("The number list was not a list of numbers.")
     except:
         print "There was a problem evaluating the number list."
     return total/length
@@ -112,8 +112,8 @@ def mean(numlist):
     try:
         total = sum(numlist)
         length = len(numlist)
-    except ValueError:
-        print "The number list was not a list of numbers."
+    except TypeError:
+        raise TypeError("The number list was not a list of numbers.")
     except:
         print "There was a problem evaluating the number list."
     return total/length
index c04a0f1d43c26cf8eb16fb0bbcb31714e3a13957..887484defabb9d68a7f99fbd8b600a91d712d169 100644 (file)
@@ -2,8 +2,8 @@ def mean(numlist):
     try:
         total = sum(numlist)
         length = len(numlist)
-    except ValueError:
-        print "The number list was not a list of numbers."
+    except TypeError:
+        raise TypeError("The number list was not a list of numbers.")
     except:
         print "There was a problem evaluating the number list."
     return total/length