KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In Python, how do I split on either a space or a hyphen? Input: You think we did this un-thinkingly? Desired output: ["You", "think", "we", "did", "this", "un", "thinkingly"] I can get as far as mystr.split(' ') But I don't know how to split on hyphens as well as spaces and the Python definition of split only seems to specify a string . Do I need to use a regex?
Tags (comma-separated)
Save Edits
Cancel