Python sort list alpha 1

Python sort list alpha

data = ['Elle', 'Miles', 'Kratos', 'Joel', 'Peter', 'Nathan']

print(sorted(data))

Here is what the above code is Doing:
1. We create a list of names.
2. We call the sorted() function and pass in the list of names.
3. The sorted() function returns a new list of names in alphabetical order.
4. We print the new list of names.

Similar Posts