Exercise: Create list
- Create a script called create_list.py that given a list of strings with words separated by spaces, create a single list of all the words.
- Skeleton:
examples/lists/create_list_skeleton.py
lines = [ 'grape banana mango', 'nut orange peach', 'apple nut banana apple mango', ] # .... print(fruits) # .... print(unique_fruites)
- Expected result:
['grape', 'banana', 'mango', 'nut', 'orange', 'peach', 'apple', 'nut', 'banana', 'apple', 'mango']
Then create a list of unique values sorted in alphabetical order.
Expected result:
['apple', 'banana', 'grape', 'mango', 'nut', 'orange', 'peach']