diff --git a/advanced-iterators.html b/advanced-iterators.html index f299960..fce7dc8 100644 --- a/advanced-iterators.html +++ b/advanced-iterators.html @@ -295,7 +295,7 @@ StopIteration 'Chris', 'Ethan', 'Sarah', 'Lizzie', 'Wesley']
list(open(filename)) idiom also includes the carriage returns at the end of each line. This list comprehension uses the rstrip() string method to strip trailing whitespace from each line.
+list(open(filename)) idiom also includes the carriage returns at the end of each line. This list comprehension uses the rstrip() string method to strip trailing whitespace from each line. (Strings also have an lstrip() method to strip leading whitespace, and a strip() method which strips both.)
sorted() function takes a list and returns it sorted. By default, it sorts alphabetically.
sorted() function can also take a function as the key parameter, and it sorts by that key. In this case, the sort function is len(), so it sorts by len(each item). Shorter names come first, then longer, then longest.