--
You received this message because you are subscribed to the Google Groups "Python GCU Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-gcu-for...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# C. sort_last
# Given a list of non-empty tuples, return a list sorted in increasing
# order by the last element in each tuple.
# e.g. [(1, 7), (1, 3), (3, 4, 5), (2, 2)] yields
# [(2, 2), (1, 3), (3, 4, 5), (1, 7)]
# Hint: use a custom key= function to extract the last element form each tuple.
def sort_last(tuples):
for s in tuples:
def last(s): return s[-1]
sorted(s, key=last)
print last(s)
return
Traceback (most recent call last):
File "/Users/Terry/Desktop/google-python-exercises/basic/list1.py", line 108, in <module>
main()
File "/Users/Terry/Desktop/google-python-exercises/basic/list1.py", line 99, in main
test(sort_last([(1, 3), (3, 2), (2, 1)]),
File "/Users/Terry/Desktop/google-python-exercises/basic/list1.py", line 65, in sort_last
sorted(s, key=last)
You're still returning None
--
--
You received this message because you are subscribed to a topic in the Google Groups "Python GCU Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-gcu-forum/BRreTa6dtYU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-gcu-for...@googlegroups.com.