Skip to content

Commit

Permalink
Update limit.py (keon#498)
Browse files Browse the repository at this point in the history
* Update limit.py

boundary

* Update limit.py

1. replace == with is 
2. remove spaces around =
  • Loading branch information
Everfighting authored and keon committed May 3, 2019
1 parent 17d7275 commit f3a4512
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions algorithms/arrays/limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@
"""

# tl:dr -- array slicing by value
def limit(arr, min_lim = None, max_lim = None):
def limit(arr, min_lim=None, max_lim=None):
result = []
if min_lim == None:
if min_lim is None and max_lim:
for i in arr:
if i <= max_lim:
result.append(i)
elif max_lim == None:
elif max_lim is None and min_lim:
for i in arr:
if i >= min_lim:
result.append(i)
else:
elif max_lim and min_lim:
for i in arr:
if i >= min_lim and i <= max_lim:
result.append(i)

else:
result = arr
return result

0 comments on commit f3a4512

Please sign in to comment.