Update absMax.py (#602)

* Update absMax.py

Fixed two bugs

* changed to abs instead of absVal
This commit is contained in:
gpapadok 2019-02-15 18:01:10 +02:00 committed by John Law
parent 3c8036432c
commit 301493094e

View File

@ -1,5 +1,3 @@
from Maths.abs import absVal
def absMax(x): def absMax(x):
""" """
#>>>absMax([0,5,1,11]) #>>>absMax([0,5,1,11])
@ -9,15 +7,15 @@ def absMax(x):
""" """
j =x[0] j =x[0]
for i in x: for i in x:
if absVal(i) > absVal(j): if abs(i) > abs(j):
j = i j = i
return j return j
#BUG: i is apparently a list, TypeError: '<' not supported between instances of 'list' and 'int' in absVal
#BUG fix
def main(): def main():
a = [-13, 2, -11, -12] a = [1,2,-11]
print(absMax(a)) # = -13 print(absMax(a)) # = -11
if __name__ == '__main__': if __name__ == '__main__':
main() main()