Published on January 26, 2024By DeveloperBreeze
Python Example: Sorting a List of Fruits
The following Python code demonstrates how to sort a list of fruits alphabetically using the sort()
method:
# Define a list of fruits
fruits = ['apple', 'banana', 'cherry', 'date', 'fig']
# Sort the list alphabetically
fruits.sort()
print('Sorted Fruits:', fruits)
Comments
Please log in to leave a comment.