我打算在列表中获取字符串值,以找到充分利用25个字符限制的子字符串的不同组合。你知道吗
我目前正在处理这个问题:
如果我有一个值列表:
lorem = ['when', 'the fox jumped over the moon']
由于列表中的第二个字符串,结果是:
limited = ['when']
lorem = ['when', 'the fox jumped', 'over', 'the moon']
我想要一个算法可以:
比如:
limited = ['the fox jumped the moon']
..
..
我希望这是清楚和有意义的。你知道吗
当前代码:
title_limited = []
counter = 0
while counter < 25:
for i in lorem:
counter += len(i)
if counter > 25: break
title_limited.append(i.title())
谢谢你的帮助。你知道吗
试试这个:
相关问题 更多 >
编程相关推荐