Quiz - 12ΒΆ

Develop the function ends_equal that, given a list of strings words, returns the number of strings with length >= 2 where the first and last character are the same.

Example:
ends_equal(["aba", "xyz", "aa", "x", "bbb"]) -> 3

Develop the function x_before that, given a list of strings words, returns another list in which all strings that start with the 'x' character are the first elements of the list. Then, the rest of the words will be arranged according to their alphabetical order. Note: Remember that sorted(list) returns a sorted list.

Examples:
x_before(["bbb", "ccc", "axx", "xzz", "xaa"]) -> ["xaa", "xzz", "axx", "bbb", "ccc"]
x_before(["ccc", "bbb", "aaa", "xcc", "xaa"]) -> ["xaa", "xcc", "aaa", "bbb", "ccc"]

Develop the function sort_tuples that, given a non-empty list of tuples, returns another list of tuples sorted in ascending order taking into account the last element of each tuple.

Examples:
sort_tuples([(1, 3), (3, 2), (2, 1)]) -> [(2, 1), (3, 2), (1, 3)]
sort_tuples([(2, 3), (1, 2), (3, 1)]) -> [(3, 1), (1, 2), (2, 3)]

You have attempted of activities on this page