Quick actions

cmd+k|ctrl+k

Navigation

Languages

Exercise 2 About using sort(),reverse(),sorted() 

Snippet info

Language

Python

Visibility

public

Author

ericmash53

Created

2026-04-02T16:27:05.93968Z

Updated

2026-04-06T12:30:42.776586Z

    # ERXERCISE
# Think of at least five places in the world you’d like to visit?

# Solution
# Place Dar es salaam City

Dar_city = ['Masaki','Oysterbay','Sea Cliff Hotel','Coco Bravo','Coco Beach'] # This is the Five place 

print(Dar_city) # list in its original order

# Use sorted() to print your list in alphabetical order without modifying the actual list

print(sorted(Dar_city)) # Output Brings the Chronogical-order Arrangment

# Show that your List is still in its Original order by printing it.

print(Dar_city) # Output Shows the Original of the List

# Now we gonna used on sort of revers()

Dar_city.sort(reverse=True)

print(Dar_city) # Output Brings in Sort() Means arranged Chronogical-order But when encourage sort(reverse = True)

Dar_city.sort()

print(Dar_city) # Output Shows The Original of the List 

# Use reverse() to Change the order of your list. Show that the order Changed

Dar_city.reverse()

print(Dar_city) # Output Shows the reverse() of the list 

# Thy Question said reverse() Show that order changed but this Said to it;s Bacl to it;s Original Order

Dar_city.sort(reverse=False)

print(Dar_city) # Output brings that brings it's original Order because i Conducted on reverse = False so that indicated that Nothing Changes.

# Use sort() To Change 
INFO