是否可以通过列表理解进行以下操作?试图存储通过循环在任何给定点看到的最大值.
def test(input):
a = input[0]
b = []
for i in input:
a = max(i,a)
b.append(a)
return b
print test([-5,6,19,4,5,20,1,30])
# returns [-5, 6, 19, 19, 19, 20, 20, 30]
Run Code Online (Sandbox Code Playgroud)