mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-31 06:33:44 +00:00
Update absMax.py (#602)
* Update absMax.py Fixed two bugs * changed to abs instead of absVal
This commit is contained in:
parent
3c8036432c
commit
301493094e
|
@ -1,5 +1,3 @@
|
|||
from Maths.abs import absVal
|
||||
|
||||
def absMax(x):
|
||||
"""
|
||||
#>>>absMax([0,5,1,11])
|
||||
|
@ -9,15 +7,15 @@ def absMax(x):
|
|||
"""
|
||||
j =x[0]
|
||||
for i in x:
|
||||
if absVal(i) > absVal(j):
|
||||
if abs(i) > abs(j):
|
||||
j = i
|
||||
return j
|
||||
#BUG: i is apparently a list, TypeError: '<' not supported between instances of 'list' and 'int' in absVal
|
||||
#BUG fix
|
||||
|
||||
|
||||
def main():
|
||||
a = [-13, 2, -11, -12]
|
||||
print(absMax(a)) # = -13
|
||||
a = [1,2,-11]
|
||||
print(absMax(a)) # = -11
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user