Question

In Python 35) Make a dictionary of all the words from the below paragraph, which are having 4 or more letters in it. • Key of the dictio

0 0
Add a comment Improve this question Transcribed image text
Answer #1
paragraph = """It's the Spice Girls part but not as you know them. Twenty years after it was first released, \
I this famous girl power anthem has been given a 21st century feminist makeover. \
I The new video is part of Project Everyone's campaign to improve the lives of women and girls everywhere, \
calling for an end to violence against girls, quality education for all and equal pay for equal work."""

# Splitting paragraph into words
words = paragraph.replace(".","").replace(",","").split(" ")

# initializing dictionary
d = {}

# Looping through each word
for x in words:
    # Checking word is of length 4 or more
    if len(x)>=4:
        # if x in dictionary
        if x in d.keys():
            # incrementing count by 1
            d[x] += 1
        else:
            # initializing count to 1
            d[x] = 1
print(d)

Output:

{"It's": 1, 'Spice': 1, 'Girls': 1, 'part': 2, 'know': 1, 'them': 1, 'Twenty': 1, 'years': 1, 'after': 1, 'first': 1, 'released': 1, 'this': 1, 'famous': 1, 'girl': 1, 'power': 1, 'anthem': 1, 'been': 1, 'given': 1, '21st': 1, 'century': 1, 'feminist': 1, 'makeover': 1, 'video': 1, 'Project': 1, "Everyone's": 1, 'campaign': 1, 'improve': 1, 'lives': 1, 'women': 1, 'girls': 2, 'everywhere': 1, 'calling': 1, 'violence': 1, 'against': 1, 'quality': 1, 'education': 1, 'equal': 2, 'work': 1}

Note: Please comment below if you have any doubts. upuote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
In Python 3 5) Make a dictionary of all the words from the below paragraph, which...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT