"print(x.sort())" prints out "None"


How come the following prints out “None”?

### Exercise 1 & 2 ###
addresses = ['221 B Baker St.', '42 Wallaby Way', '12 Grimmauld Place', '742 Evergreen Terrace', '1600 Pennsylvania Ave', '10 Downing St.']

# Sort addresses here:
sorted_addresses = addresses.sort()


Course: Sorting Lists I

edit: topic can be deleted as i already found out what i was missing


for the people running into the same problem: .sort() modifies the list directly and returns None


If you would like to leave the addresses list in its original order and assign a sorted version of it to sorted_addresses, use the sorted built in function, as follows …

sorted_addresses = sorted(addresses)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.