Home > other >  A Python program to change the wrong topic
A Python program to change the wrong topic

Time:09-27

Program to change wrong topic description is as follows: use the name of its infinite loop way receives input from the keyboard, to save name on a list, press Q end input; The names of the input contains Q, the same end of the input, output the final name list, the end of the program,???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? Programming in the template found 3 mistakes, please find and modify the code and test, this topic support OJ,
Input/output
Example 1 Q []??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
Program exits??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
Example 2 Mary?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? [' Mary ']????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
Queen?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? Program exits
Ls=[]
While True:
S=input (" ")
If s="Q" :
Break
Flag=True
For c in s:
If c=="Q" :
Flag=False
Break
The if flag:
Break
Ls. Append (s)
Print (ls)
Print (" program exits ")
O great god answer!!!!!!!!!!!!!!!

CodePudding user response:

 
Ls=[]
While True:
S=input (" ")
If s=="Q" :
Break
Flag=True
For c in s:
If c=="Q" :
Flag=False
Break
If not flag:
Break
Ls. Append (s)
Print (ls)
Print (" program exits ")
  • Related