Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python max_minus_min_abs

def max_minus_min_abs(first_num, second_num):
    return max(first_num, second_num) - min(first_num, second_num)
    print(max_minus_min_abs(15, 4))

What am I doing wrong here? It’s not printing a number at all.

def max_minus_min_abs(first_num, second_num):
    return max(first_num, second_num) - min(first_num, second_num)
    print(max_minus_min_abs(15, 4))

I also tried enter numbers where it says return max.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

One reason is because you need to take the max and min of a list, so you would want to do something like this

def max_minus_min_abs(first_num, second_num):
    return max([first_num, second_num]) - min([first_num, second_num])

print(max_minus_min_abs(15, 4))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading