+ 1

If...elif...else

'''Is there a way to shorten this code or is this the only way to do it? May be using lists, and conditional min/max on a list or something. This would be outside of calling a function as I would want this to be one function. I am also trying to do this even if the list imports more than three numbers. It does not however matter if a function is called as a parameter of this would be function. No worries about any return statements I'm just looking for a way to do this outside a function so that i can then figure out how to put it into one properly. I tested all possible outcomes manually, and passed. This is under my codes also if you want to test it.''' x=1 ## int(input("Enter an integer for x:")) y=2 ## int(input("Enter an integer for y:")) z=3 ## int(input("Enter an integer for z:")) #if there is one largest intiger and no two integers are the same if x > y and x > z and y != z: print("x is the largest integer") elif y > x and y > z and x != z: print("y is the largest integer") elif z > x and z > y and x != y: print("z is the largest integer") #if x and y are the same elif x == y and x != z and y != z : if x > z and y > z: print("x and y are the same and are greater than z") else: print("x and y are the same and are less than z") #if x and z are the same elif x == z and x != y and z != y: if x > y and z > y: print("x and z are the same and are greater than y") else: print("x and z are the same and are less than y") #if y and z are the same elif y == z and y != x and z != x: if y > x and z> x: print("y and z are the same and are greater than x") else: print("y and z are the same and are less than x") # if all intigers are the same else: print("All are the same number")

23rd Oct 2017, 5:41 PM
Juan Hernandeztorres
Juan Hernandeztorres - avatar
1 Resposta
0
check it... it serves the purposes https://code.sololearn.com/c3gaWhXL82nF/?ref=app
23rd Oct 2017, 6:02 PM
sayan chandra
sayan chandra - avatar