Question while reading "What Are Some Common Methods for Tuples?"

If you want to create a new list of values in reverse order, then you can use the reverse argument like this:

programming_languages = ('Rust', 'Java', 'Python', 'C++', 'Rust', 'Python')

print(sorted(programming_languages, reverse=True))

# Result
# ['Rust', 'Rust', 'Python', 'Python', 'Java', 'C++']

Wouldn’t this return

[‘Python’, ‘Rust’, ‘C++’, ‘Python’, ‘Java’, ‘Rust’]

?

Hi @LingGeekRain

The sorted function returns a new list that is alphabetically sorted, the reverse attribute set to True reverses that order.

Happy coding

1 Like

Oh gosh, talk about me getting confused. :woozy_face: For some reason, I thought I was looking at .reverse()

1 Like