【发布时间】:2016-09-01 23:57:34
【问题描述】:
我正在尝试使用split() 方法返回列表索引的句子长度<=。如果我输入某个索引的确切长度,这可行,但< 似乎没有做任何事情。这是我的代码:
stories = [['With bloody hands, I say good-bye.'],
['TIME MACHINE REACHES FUTURE!!! ... nobody there ...'],
["Not In My Job Description: Make sure it's done by the end of the day Jones.\nBut, sir, it's not in my ....\nJust do it, and remember, no blood."]]
def len_sentence():
search = int(input("Enter int"))
for i in stories:
len1 = (i[0][0:].split(' '))
if len(len1) <= search:
print(i)
len_sentence()
整数 1-5 的用户输入不返回任何内容。如果我将<= 替换为>=,则可以。为什么< 什么都不做?
【问题讨论】:
标签: python list python-3.x split python-3.5