You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
eslopfer da345c7f5a docs(clean_the_list): add subject description 2 years ago
..
README.md docs(clean_the_list): add subject description 2 years ago

README.md

clean_the_list

Instructions

Create a file shopping.py that contains a function clean_list which takes in a list of strings and performs the following operations on each list item:

  • Removes all spaces before and after (but not between words).
  • Capitalizes the first letter (first letter only, other ones should be to lowercase).
  • Adds its index number before a separator x/ .
  • An empty list as input should return an empty list as output.
  • And don't forget the milk !!!! (add it at the end of the list if missing).

Usage

Here is an example of how to use the clean_list function:

import shopping
shopping_list = ['tomatoes', 'pastas', 'milk', 'salt']
print(shopping.clean_list(shopping_list))

This will output:

['1x/ Tomatoes', '2x/ Pastas', '3x/ Milk', '4x/ Salt']

References

string strip string capitalize