Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/bin/env python3 

2 

3"""Solution to chapter 7, exercise 29: flatten""" 

4 

5 

6def flatten(mylist): 

7 """Expects to get a nested list (a list of lists) 

8as input. Returns a flattened list, containing the 

9elements of mylist in order, as output. 

10""" 

11 return [one_element 

12 for one_sublist in mylist 

13 for one_element in one_sublist]