Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ['xxxxxxn', 'xxxxxxn', 'xxxxxxn', 'xxxxxxn', 'xxxxxx n', 'xxxxxxn',
- ' xxxxxx n', 'xxxxxx n', 'xxxxxxn', ...]
- AttributeError: 'list' object has no attribute 'strip'
- [s.strip().title() for s in my_list]
- a = ['xxxxxxn', ' xxxxxx n', 'xxxxxx n', 'xxxxxxn', ...]
- a = [x.strip().title() for x in a]
- my_list=['xxxxxxn', 'xxxxxxn', 'xxxxxxn', 'xxxxxxn', 'xxxxxx n', 'xxxxxxn', ' xxxxxx n', 'xxxxxx n', 'xxxxxxn']
- def format_string_from_list(_str):
- return _str.strip().title()
- my_new_list=[format_string_from_list(_str) for _str in my_list]
- print my_new_list
- >>> ['Xxxxxx', 'Xxxxxx', 'Xxxxxx', 'Xxxxxx', 'Xxxxxx', 'Xxxxxx', 'Xxxxxx', 'Xxxxxx', 'Xxxxxx']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement