This is a scrapping from a selenium scrap dump:
['The Quest for Ethical Artificial Intelligence: A Conversation with
Timnit Gebru', 'Mindfulness Self-Care for Students of Color', 'GPA: The Geopolitical landscape of the Olympic and Paralympic Movements', 'Interfaith Discussions', 'Mind the Gap', 'First-Year Arts Board Open House', 'Self-Care Night with CARE and BGLTQ Specialty Proctors', 'Drawing Plants & Flowers - Sold Out']
I have to pass this to an algorithm but as you can see, although all of them are perfectly encased within quotes, as the sentence breaks after "conversation with" and this is affecting my input. I tried removing whitespaces, didn't work. Any help will be highly appreciated.
CodePudding user response:
You can't type a string on multiple lines unless you're using triple quotation marks.
i.e. The first item (string) in your list is
['The Quest for Ethical Artificial Intelligence: A Conversation with
Timnit Gebru']
You should keep the string on one line as follows.
['The Quest for Ethical Artificial Intelligence: A Conversation with Timnit Gebru']
Or you could use a triple quotation, as I mentioned.
['''The Quest for Ethical Artificial Intelligence: A Conversation with
Timnit Gebru''']
If you'd like to make your list visible and neat aswell, I'd recommend breaking between commas in the list for example:
['The Quest for Ethical Artificial Intelligence: A Conversation with Timnit Gebru',
'Mindfulness Self-Care for Students of Color',
'GPA: The Geopolitical landscape of the Olympic and Paralympic Movements',
'Interfaith Discussions',
'Mind the Gap',
'First-Year Arts Board Open House',
'Self-Care Night with CARE and BGLTQ Specialty Proctors',
'Drawing Plants & Flowers - Sold Out']
CodePudding user response:
You could try
string_list = ['The Quest for Ethical Artificial Intelligence: A Conversation with
Timnit Gebru', 'Mindfulness Self-Care for Students of Color', 'GPA: The Geopolitical landscape of the Olympic and Paralympic Movements', 'Interfaith Discussions', 'Mind the Gap', 'First-Year Arts Board Open House', 'Self-Care Night with CARE and BGLTQ Specialty Proctors', 'Drawing Plants & Flowers - Sold Out']
string_list = [str.replace("\n", " ") for str in string_list]