我需要这个函数来告诉我列表中正数的最长序列。max()函数在Jython中如何工作?
def longestSequencePos(nums):
index = 0
list = []
integ = 0
for obj in nums:
if obj > 0:
index = index +1
else:
list.append(index)
index = 0
return max(list)
列表应包含正数序列的所有长度,但最大值函数不起作用。
它以什么方式不起作用? –
切勿使用'list'作为变量名称。 –
调试:'print list',或者'print better_name_than_list' –