18 lines
455 B
Python
18 lines
455 B
Python
|
def maxPeriod(valueList, mindestwert):
|
||
|
"""
|
||
|
Gibt die Länge der am meinsten hintereinander liegenden Listenelemente aus valueList zurück,
|
||
|
die größer oder gleich mindestwert sind.
|
||
|
"""
|
||
|
maxlen = 0
|
||
|
current_len = 0
|
||
|
for i in valueList:
|
||
|
if i >= mindestwert:
|
||
|
current_len += 1
|
||
|
else:
|
||
|
if current_len > maxlen:
|
||
|
maxlen = current_len
|
||
|
current_len = 0
|
||
|
return maxlen
|
||
|
|
||
|
print(maxPeriod([20, 22, 23, 21, 19, 18, 20, 22, 23, 23, 24, 22, 21], 22))
|