198k views
1 vote
Which of the following would alphabetize and print this list?

cities = [“New York”, “Delhi”, “Shanghai”, “London”, “Paris”]

A.
print(sorted(cities))

B.
print(alpha(cities))

C.
print(alphabetize(cities))

D.
print(sort(cities))

1 Answer

4 votes

The correct option would be A.

So the code to alphabetize and print the list in ascending order would be:

cities = ["New York", "Delhi", "Shanghai", "London", "Paris"]

print(sorted(cities))

Option B and C are not valid Python functions, and option D has an incorrect function name.

User Padis
by
7.6k points