How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask George Sibiya Your Own Question
George Sibiya
George Sibiya, Computer Hardware Engineer
Category: Programming
Satisfied Customers: 182
Experience:  PhD in Computer Science
Type Your Programming Question Here...
George Sibiya is online now
A new question is answered every 9 seconds

Im trying to iterate through a list of lists (comprised of

Customer Question

Im trying to iterate through a list of lists (comprised of strings) and count the number of times a sequence of characters is in each list
JA: What programs and versions are you using?
Customer: Python 3
JA: What is your ideal outcome? How can we solve this for you?
Customer: Have the code for how to count two separate things: the number of lines that contain the word union in any case and the number of instances of instances of the word union in any case
JA: Anything else you want the programmer to know before I connect you?
Customer: I can provide the materials Ive used up to this point
Submitted: 9 months ago.
Category: Programming
Customer: replied 9 months ago.
1. Open File
2. Parse file into a list of lists, variable named: file_data, where every line is a list of words.
3. Iterate through the file_data, and count two separate things:
Number of lines that contain the word UNION in any case
Number of instances of the word of UNION in any caseThe results should be for number of lines 389 and number of instances 392; this is including words that contain union.
Customer: replied 9 months ago.
example of the lists of lists:['moderation. Union will enable us to do it. Disunion will will add'], ['another victim to his triumphs. Let Americans disdain to be the'], ['instruments of European greatness! Let the thirteen States', ' bound'], ['together in a strict and indissoluble Union', ' concur in erecting one'], ['great American system', ' superior to the control of all transatlantic'], ['force or influence', ' and able to dictate the terms of the connection'], ['between the old and the new world!'], ['PUBLIUS.'], ["``Recherches philosophiques sur les Americains.''"], [''], ['FEDERALIST No. 12'], [''], ['The Utility of the Union In Respect to Revenue'],
Expert:  George Sibiya replied 9 months ago.


Welcome to just answer and thank you for utilizing our services.

I will work on it and post back in the next two hours.



Customer: replied 9 months ago.
file_data = []
with open('../../../datasets/hamilton-federalist-548.txt') as inputfile:
for line in inputfile:
file_data.append(line.split())is where I'm at currently
Expert:  George Sibiya replied 9 months ago.

ok no prob

Expert:  George Sibiya replied 9 months ago.

Please try this

and let me know if there are any issues

Expert:  George Sibiya replied 9 months ago.

Hi, please feel free to rate me