Question: Question 2 ( 1 . 5 pts ) For loop The following are words taken from two pieces of news: News 1 from CBS: 'TikTok',

Question 2(1.5pts) For loop
The following are words taken from two pieces of news:
News 1 from CBS:
'TikTok', 'users', 'soon', 'find', 'popular', 'social', 'media', 'service', 'either', 'under', 'new',
'ownership', 'or', 'although', "wouldn't", 'happen', 'immediately', 'outright', 'ban', 'in','U.S.',
'On', 'Saturday,', 'House', 'passed', 'legislation', 'would', 'ban', 'TikTok', 'from', 'operating', 'in',
'U.S.','if', 'popular', "platform's", 'China-based', 'owner', "doesn't", 'sell', 'stake', 'within', 'year',
'The', 'bill', 'will', 'next', 'head', 'Senate', 'where', 'expected', 'pass', 'buoyed', 'attachment', 'larger',
'foreign', 'aid', 'package', 'for', 'for', 'Ukraine', 'Israel', 'gained', 'bipartisan', 'support'
News 2 from CNN:
'Foreshadowing', 'legal', 'strategy', 'TikTok', 'already', 'publicly', 'opposed', 'bill', 'as','an',
'infringement', 'on', 'users', 'First', 'Amendment', 'rights', 'Supporters', 'of', 'legislation',
'contrast', 'have', 'said', 'necessary', 'measure', 'protect', 'Americans', 'personal', 'data', 'have',
'pushed', 'back', 'on', 'characterizations', 'of','as', 'flat-out', 'ban', 'Some', 'legal', 'experts', 'on',
'First', 'Amendment', 'have', 'suggested', 'TikTok', 'ban', 'have', 'case', 'noting', 'courts', 'have',
'tended', 'look', 'at', 'ultimate', 'impacts', 'of','of', 'challenged', 'laws', 'on', 'Americans', 'speech',
'not', 'just', 'their', 'stated', 'intent'
Write a program to do the following:
1. Create two lists to hold the words from the two news and use a for loop to convert all
words to lower case. (Hint: use enumerate() function and .lower() method)
2. Use a for loop to remove all stop words from the two lists and output number of words
left. Stop words are: 'under', 'in','on', 'from', 'the', 'for', 'as','an','of','at', 'have'
3. Use a for loop to create a dictionary of word frequency of all unique words used in the
combined words list.
4. Optional 0.3 Extra Credit
Find the most frequently mentioned word(s).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!