Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple way to execute without using an array/list? #12

Open
gsloup opened this issue Sep 19, 2017 · 2 comments
Open

Simple way to execute without using an array/list? #12

gsloup opened this issue Sep 19, 2017 · 2 comments

Comments

@gsloup
Copy link

gsloup commented Sep 19, 2017

Is there a simple way to execute this function without literally going through every single parameter and saying if a > b and a > c... etc (without using a list or array)? I've been looking at this and cannot think of how to simplify the code without going into subjects we haven't covered yet. Thanks.

This is literally the extent of code I had to use to correctly run the function and I know it is very inefficient:

(with all of the correct indentation)
def greatest_parameter(a, b, c, d, e):
if a > b and a > c and a > d and a > e:
return a
else:
if b > c and b > d and b > e:
return b
else:
if c > d and c > e:
return c
else:
if d > e :
return d
else:
return e

@sprg24
Copy link

sprg24 commented Sep 19, 2017

I just used the max operator

def greatest_parameter(a, b, c, d, e):
return max(a, b, c, d, e)

@gsloup
Copy link
Author

gsloup commented Sep 19, 2017

@sprg24 thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants