[Tutor] Question in regards to my assignment

2014-01-18 Thread Jackie Canales
I have with my assignment. class Score:     'A subclass of the object.'          def __init__(self, init):         'Sets the initial score to the object and sets the number of scores that have contributed to the total to 1.'         self.x = 1         self.init = int(init)         self.total = i

[Tutor] Count Help

2013-10-24 Thread Jackie Canales
let say i have a file with random letters of  A, AB, C, CD, AC, A, D, CD, DD, C, B, AB, CD, AB How do i count the occurrence of each individual item. def occurence(name):     infile = open('bloodtype1.txt', 'r')     lst = infile.read()     infile.close()     print(lst.count('AB')) # 3     print(

Re: [Tutor] Looking for Words - Help

2013-10-12 Thread Jackie Canales
from string import punctuation #helper function def strip(text):     'returns text with all punctuation removed'     for symb in punctuation: #import from string         text = text.replace(symb, ' ')              return text #helper function def wordin(s,t):     'does word s occur in text t'    

[Tutor] Looking for Words - Help

2013-10-11 Thread Jackie Canales
Need assistance with a questions in regards to python: 1. function occurs(name, word) which looks for a word in the file with name name. 2. for each occurrence of the word we want to display its context by showing the 5 words (or so) preceding and following the occurrence, e.g. '... a man to set