I have the code, Can you debugged it to meet the following requirements? You can use
Question:
I have the code, Can you debugged it to meet the following requirements?
You can use any sentence to test, I will then tested with the ones I created.
* Please do not change the structure of the function drastically. I need to learn how to work the Buggs on it, if you change or if you create your own better version, it it wont be the same.
If I run it as it its the first bug is about the object does not have attribute count.
I did divide using list() so not sure why is this happening.
- Once that is done, run it again and If there is another bug fix that one two. This lesson is about debugging the function.
I have already have my samples of the sentences to read, I just need a functioning code to test it against.
Can you please help me with the bugs and explain me how you resolved them for future references?
def count_letter_e(loc, count_accented = True, count_uppercase = True): # Open and read the file with open(loc+".txt", encoding = "utf-8") as test_file: text = test_file.read() test_file = test_file.list()#to change from objet # List of all e's to look for e_list = ['e', 'é', 'ê', 'è', 'E', 'É', 'Ê', 'È'] #dictionary with all e counts letter_counts = {} for e in e_list: letter_counts[e] = test_file.count('e') # Variable that will return the desired integer sum_counts = 0 if count_uppercase and count_accented: # When ignoring everything, we want to add up all the counts text = text.lower() sum_counts = sum(letter_counts) elif count_accented == True and count_uppercase == False: # When ignoring accents, we want to add up the relevant counts e_counts = [letter_counts[ell] for ell in e_list] sum_counts = sum(e_counts) elif count_uppercase == False and count_accented == True: # When ignoring case, we want to add up the relevant counts e_counts = [letter_counts[ell] for ell in e_list] sum_counts = sum(e_counts) elif count_uppercase == False and count_accented == False: # When not ignoring anything, we want to count the 'e's count = text.count('e') return(sum_counts)
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill