Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
我假设 punc 是标点符号的选项卡列表。
这对你有用吗?
输出 :
I assumes
punc
is tab list of punctuation.Is this working for you ?
output :
让我们看一下这 3 个语句,每个语句在循环的每次迭代中执行:
因此,对于每个单词,您将创建一个新列表,将该单词放入其中,然后打印它。相反,您想在循环之前创建一个新列表,放入所需的所有单词,然后在循环完成后打印所有单词。
Let's look at those 3 statements, each executed on each iteration of the loop:
So for every word, you are creating a new list, putting that word into it and then printing it. Instead you want to create a new list before the loop, put all the words you want and then print all of them after the loop is finished.
如果您追加也没关系,因为上面的行将 lsit 擦除干净。像
c_list = []
一样摆脱它,并将其放在主循环之前,然后将print(c_list)
放在主 for 循环之外和之后,看看是否有效。Doesnt matter if you append since the line above wipes the lsit clean. Get rid of this like
c_list = []
and put it before the main loop, and put theprint(c_list)
outside and after the main for loop and see if that works.