Skip to content

Instantly share code, notes, and snippets.

@charlesreid1
Created February 5, 2016 00:27
Show Gist options
  • Save charlesreid1/37484f52822f249c107d to your computer and use it in GitHub Desktop.
Save charlesreid1/37484f52822f249c107d to your computer and use it in GitHub Desktop.
line = "this, is, some, really, weird,whitespace"
# split the string at commas, resulting in a list
tokens = line.split(",")
# tokens still have whitespace
print tokens
# list comprehension to strip whitespace
nowhitespace = [a.strip() for a in tokens]
# yay! no whitespace!
print nowhitespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment