【发布时间】:2018-07-21 02:30:23
【问题描述】:
例如,我有这样的文字:This is a good reason to stop.(字数总是大于 5)
words = ['This', 'is', 'a', 'good', 'reason', 'to', 'stop']
flashcards_count = ciel(len(word) / 3)
我想要的结果:
[
'This __ a good ______ to ____.'
'____ is a ____ reason __ stop.'
'This is _ good reason to stop.'
]
您可能会注意到,我尽量避免按顺序放置空格,除非它是最后一张抽认卡。
因此,为此,我将words 洗牌并将其分成 3 个以制作每个抽认卡,但结果可能是这样的:
[
'This is a ____ ______ __ stop.'
'____ __ _ good reason to stop.'
'This is a good reason to ____.'
]
【问题讨论】:
-
我不确定我是否理解 - 你的意思是你想洗牌一个列表,试图确保每个单词之间至少有一个“新”单词和它以前的邻居?
-
是的,没错,我真的很难解释
标签: javascript python