Saturday, March 19, 2016

Missing list in Python

# missing list

colors = ["red", "green", "blue", "violet", "yellow", "orange", "purple"]
print colors # prints list as above
colors.sort()
print colors # prints sorted list
sorted_colors = colors.sort()
print sorted_colors # prints None
print colors.sort() # prints None

Wow, just wow.  Counter-intuitive.  Not the way my brain works.

No comments: