Skip to content

Instantly share code, notes, and snippets.

@elpargo
Created January 10, 2014 06:54
Show Gist options
  • Save elpargo/8347945 to your computer and use it in GitHub Desktop.
Save elpargo/8347945 to your computer and use it in GitHub Desktop.
For Conrado :)
>>> str1 = 'There are two types of people in the world'
>>> str2 = 'Hello my name is caonabo welcome to dominican republic'
>>> str2.split(' ')
['Hello', 'my', 'name', 'is', 'caonabo', 'welcome', 'to', 'dominican', 'republic']
# El default de split es ASCII 32 so
>>> str2.split()
['Hello', 'my', 'name', 'is', 'caonabo', 'welcome', 'to', 'dominican', 'republic']
#no te compliques con chr
>>> [s for s in str1.split() if s[0] == 'w']
['world']
#asi es aun mas facil
>>> [s for s in str1.split() if s == 'world']
['world']
#check this one :D
>>> print " ".join([i for i in ["Hello","world"] if i in "{} {}".format(str1,str2)])
Hello world
#Wlecome :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment