jeudi 26 mars 2015

Python to Transforming elements in a list when split

Hello all… could you please help me with the question below?



Long_string = """
"Fifty Shades of Grey” shakeup: Kelly Marcel not returning for Sequel
"""


A need to break down the string into words. I do:



text_to_list = testing.split()


the output is:



['\xa1\xb0Fifty', 'Shades', 'of', 'Grey\xa1\xb1', 'shakeup:', 'Kelly', 'Marcel', 'not', 'returning', 'for', 'Sequel']


however some of those have special meanings when together, like the quoted “Fifty Shades of Grey”, and people’s name of together capitalized words like “Kelly Marcel”.


So I want to turn them into “Fifty-Shades-of-Grey” and “Kelly-Marcel” when they are split.


How can I do that? Thanks.


Aucun commentaire:

Enregistrer un commentaire