lab7 - alist.remove('or') for i in alist: firstLetter =...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
def numberWords (sentance): return list(sentance).count(' ') + 1 def numberWords2 (sentance): return len(sentance.split()) def getMin (alist): minSoFar = alist[0] for item in alist [1:]: if item < minsoFar: minSoFar = item return minSoFar def acronymize (text): newText= "" alist = text.split() for i in alist: firstLetter = i[0] newText = newText + firstLetter return newText def acronymize2 (text): newText= "" alist = text.split() ''' 'of' in alist: alist.remove('of') for ('in') in alist: alist.remove('in') for ('on') in alist: alist.remove('on') for ('a') in alist: alist.remove('a') for ('or') in alist:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: alist.remove('or') for i in alist: firstLetter = i[0] newText = newText + firstLetter return newText ''' potLuck = {'Alice': &quot;shrimp cocktai&quot;, 'Bob': &quot;salad&quot;, 'Carol': 'cake', 'Dave':'lasagna'} potLuck['Eve'] = 'garlic bread' print ('Alice' in potLuck) del potLuck ['Bob'] print (potLuck.get('Carol', 'Nothing!')) print (potLuck.get('Frank', 'Nothing!')) print(potLuck.keys()) print(potLuck.values()) def makeDictionary(names, scores): dictionary = {} for name in names: score = scores[names.index(name)] dictionary[name] = score return dictionary...
View Full Document

Page1 / 2

lab7 - alist.remove('or') for i in alist: firstLetter =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online