2014-04-07 + HW reminder

posted Apr 7, 2014, 5:33 AM by Samuel Konstantinovich   [ updated Apr 7, 2014, 6:26 AM ]
REMINDER: Homework (madlibs) due on homework server tonight 1159pm.
HOMEWORK: How can we remove the punctuation from the wordList (at the end of the lecture)? Write a function. Bring in a copy printed with a header

Find the syntax errors in this code, write a correction for it.
def madness(a,b,c):
    while i<b
    if a=>100:
        print "Big number:"+a
            print 'too small to care'

Evaluate each expression: 
1. 3*('abc'.replace('b','x',2))
2. (3*'abc').replace('b','x',2)
3. "Spartans".split('a')
4. 'x'.join( [ 'a','e','_','i' ] )
5. 'batter'.find('T')
6. 'Hey'.swapcase().find('E')
7. "abba".split('a')

text0='''Hey! listen!
Hey, Hey, Hey!
Please: Listen!!!'''
wordList=text0.split(" ")

#How can we split all of the words in this text?
#How can we remove the punctuation from the words?

print wordList

regarding split:

split has 2 optional parameters:
text.split( [ separator] [, maxSplits ] )

maxSplits is the upper limit of separations that will be made.
separator is the string that will be used as the place to split.

if you leave out the separator split works with a different algorithm:
Every block of whitespace acts as a SINGLE separator! This is really useful. Tab,Space,NewLines (in any quantity) will make one separator.