Situatie
The sorted() function sorts the elements of a given iterable in a specific order (ascending or descending) and returns it as a list.
Solutie
Pasi de urmat
py_list = [‘e’, ‘a’, ‘u’, ‘o’, ‘i’]
print(sorted(py_list))
py_string = ‘Python’
print(sorted(py_string))
py_tuple = (‘e’, ‘a’, ‘u’, ‘o’, ‘i’)
print(sorted(py_tuple))
Output:
[‘a’, ‘e’, ‘i’, ‘o’, ‘u’]
[‘P’, ‘h’, ‘n’, ‘o’, ‘t’, ‘y’]
[‘a’, ‘e’, ‘i’, ‘o’, ‘u’]
Leave A Comment?