subject :
There are Chinese recombined sentences when learning Chinese , There are also recombined sentences in English , Define a function comb(sentence), Its function is to confuse words in an English sentence , And connect the disordered words with a space , Then the output . If the words in the sentence
Less than or equal to 2 One output : The word of the original sentence is less than or equal to 2 individual .( Note that all strings in the program use double quotation marks "" Express ) Please put the number (1)~(7) And the corresponding underline are deleted , Fill in the blanks to complete the statements in the program , You cannot modify existing code .
import random
def comb(sentence): # Define a function , Parameter is sentence
words=(1)() #1 Separate the words
print("-"*60)
if len(words)==1 (2) len(words)==2: #2 If the word in the sentence is less than 2 individual , Do not disturb , Output "
The word of the original sentence is less than or equal to 2 individual "
print(" The word of the original sentence is less than or equal to 2 individual ")
else:
jumble=[]
while (3): #3 Make a mess of the words in the sentence
site = (4)(len(words)) #4
jumble.(5)__ #5
words=_(6) #6 When slicing, use parentheses if the position is an expression () Cover up
s=(7)(jumble) #7 Join the words with a space
print(" The word combination after the sentence is out of order is :\n",s)
if name=="main":
txt="The Beijing Organising Committee for the 2022 Olympic and Paralympic Winter Games is a public institution with legal person status"
print(" The original sentence is :\n", txt)
comb(txt)
Personal home page : Huang Xia
It was a few years ago , Sound