Guest User

Untitled

a guest
Jan 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. def replace_chars(stringa, listb):
  2. '''A function to return stringa by removing the list of characters from listb'''
  3. for x in listb:
  4. stringa = stringa.replace(x, ' ')
  5. return stringa
  6. if __name__ == "__main__":
  7. import test
  8. test.testEqual(replace_chars(" SamplEam*",["p", "E", "*"]), " Sam l am ")
  9.  
  10. import myfunctions
  11. import string
  12.  
  13. def main():
  14.  
  15. punc = list(string.punctuation)
  16. punc.remove(''')
  17. filename = input('Enter file name to read: ')
  18. num = 1
  19. with open( filename ) as z:
  20. for a in z.fileread:
  21. a = a.lower()
  22. a = a.rstrip()
  23. a = lstrip()
  24. a = myfunctions.replace_chars(a,punc)
  25. print("{0}:{1}".format(count,line))
  26. num += 1
  27. main()
  28.  
  29. AttributeError: '_io.TextIOWrapper' object has no attribute 'fileread'
  30.  
  31. 9:grandson mom can't you tell him i'm sick
  32. 10:mother you're sick that's why he's here
Add Comment
Please, Sign In to add comment