Struggling trying to create a function def of how to return three accepted integers and into a tuple in a sorted format from least to greatest depending if ascending is true. How would I go about coding this out? Would I use a for loop with if statements whether its ascending? I have a general idea for the sorting using "sorted(list)" and "sorted(list, reverse=True)."
Function code I have so far:
def sort3(x,y,z, ascending=True):
This should do the trick:
def sort3(x, y, z, ascending=True): return tuple(sorted([x, y, z], reverse=not ascending))