string sorting and output

Source: Internet
Author: User

story= ' I ' m hurting, baby, I ' m broken down

I need your loving, loving, I need it now

When I ' m Without You

I ' m something weak

You got me begging

Begging, I ' m on my knees

I don ' t wanna is needing your love

I just wanna is deep in your love

And it ' s killing me when you ' re away

Ooh, Baby,

' Cause I really don ' t care where is

I just wanna be there where is

And I gotta get one little taste

Your sugar

Yes, please

Won ' t come and put it down on me

I ' m right here, ' cause I need

Little Love and Little sympathy

Yeah You show me good Loving

Make It Alright

Need a little sweetness in my life

Your sugar

Yes, please

Won ' t come and put it down on me

My Broken Pieces

You pick them up

Don ' t leave me hanging, hanging

Come give me some

When I ' m without Ya

I ' m so insecure

You is the one thing

The one thing, I ' m living for

I don ' t wanna is needing your love

I just wanna is deep in your love

And it ' s killing me when you ' re away

Ooh, baby, "'
Story = Story.lower () #字符串变小写
For i in ',.?! ':
Story =story.replace (i, ")
Story = Story.split (') #字符串变单词列表
Exp = {', ' I ' m ', ' and ', ' it ', ' don ' t '}

DIC = {}
Keys = set (story)-exp# a collection of keys for a word that gets a grammatical component
For a in keys:
Dic[a] =story.count (a)

b = List (Dic.items ())
B.sort (key= Lambda x:x[1],reverse=true) #列表从大到小排序

For I in range (15):
Print (B[i]) #输出排名前十五的元组

string sorting and output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.