Home > other >  Feel I write very complicated, have great god did help me have a look at simplifying thinking.
Feel I write very complicated, have great god did help me have a look at simplifying thinking.

Time:12-03

A="" "winkle Twinkle Little Star - Jewel
Lyrics by Sophia Sun
Twinkle, Twinkle, little star,
How I wonder what you are.
Up above the world so high,
Like a diamond in the sky.
When the blazing sun is gone,
When he nothing shines upon,
Then you show your little light,
Twinkle, Twinkle, all the night.
Then the traveller in the dark,
Thanks you for your tiny spark,
He could not see which way to go,
If you did not twinkle so.
In the dark blue sky you keep,
And, through my curtains peep,
For you never shut your eye,
Till the sun is in the sky.
As your bright and tiny spark,
Towns the traveller in the dark.
My I know not what you are,
Twinkle, Twinkle, little star.
Twinkle, Twinkle, little star.
How I wonder what you are.
Up above the world so high,
Like a diamond in the sky.
Twinkle, Twinkle, little star.
How I wonder what you are.
How I wonder what you are. "" "
Def danci (n) :
A={}
N=n.l power ()
For I in n.s plit () :
If I==", "[1] or [1] I==" ":
J=i.r eplace (I [1], "")
If j, not in a:
A [j]=1
The else:
A [j] +=1
The else:
J=I
If j, not in a:
A [j]=1
The else:
A [j] +=1
C=[]
B=zip (a.k eys (), Dr. Alues ())
For I in b:
C.a. ppend (I)
For I in range (len (c) - 1) : # outer loop three times I respectively 0,
For j in range (len (c) - I - 1) : # j respectively 0 ~ 2, 0, 0 ~ 1
If a float (c [j] [1]) & gt; Float (c [m + 1] [1]) :
C [j], c [j + 1)=c [j + 1], c [j]
For I in range (1, len (c)) :
Print (c [I])
Danci (a)

Statistics a number of words in a string, and output from the word number from big to small,

CodePudding user response:

Generate a dictionary after code can change like this, simply

 

B=sorted (Anderson, tems (), key=lambda x: x [1], reverse=True)
For I in b:
Print (I)

CodePudding user response:

 from the collections import Counter 
A=...
L=filter (lambda x: x!=' ', a.r eplace (' \ n ', '). The replace ('. ', '). The replace (', ', '). The split (", "))
Print (sorted (Counter (l). The items (), key=lambda item: the item [1], the reverse=True))
  • Related