We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7980300 commit 33078e4Copy full SHA for 33078e4
1 file changed
Trinket_Ultrasonic_Rangefinder/code.py
@@ -80,6 +80,12 @@ def find_mode(x):
80
should mode not be found
81
"""
82
n = len(x)
83
+
84
+ if n == 0: # If somehow there is a null array
85
+ return 0;
86
87
+ if n == 1: # In trivial case of a one element array
88
+ return x[0]; # just return the element as the mode.
89
90
max_count = 0
91
mode = 0
0 commit comments