2

I'm doing some homework for my python programming class and I just wanted to know if it was possible to set any variable c equal to the greater of a and b without using an if statement.

c = bigger(a, b)

Just a thought since swapping two variables in python is so easy (a, b = b, a) that this might also be.

All help appreciated :)

AdminBenni
  • 321
  • 2
  • 11

1 Answers1

1

I think you're looking for the built-in max () function - but check your assignment to find out if you're allowed to use it, sometimes the point of an assignment is to make you implement the feature by yourself.

bruno desthuilliers
  • 75,974
  • 6
  • 88
  • 118
  • It's ok to use it since the main objective is not to do this however the method I chose to solve the problem requires me to do this and I really didn't want to add an if then switch to the code if I didn't need to. – AdminBenni Nov 23 '16 at 18:57
  • And thanks for the help – AdminBenni Nov 23 '16 at 18:57