aranthe ([personal profile] aranthe) wrote in [community profile] intro_to_cs 2010-01-28 04:55 pm (UTC)

Or... is there a way to select the smallest value in a tuple? I'm sure there is.

Yes, you can use the sorted function on a tuple:

myTuple = 3, 1, 2
sortedList = sorted(myTuple)

When you use sorted on a tuple, it returns a sorted list of the tuple's elements. Then all you have to do us peel off index 0, as you did above.


Post a comment in response:

This community only allows commenting by members. You may comment here if you're a member of intro_to_cs.
(will be screened if not on Access List)
(will be screened if not on Access List)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting