+ 1
Beginner Task: Find the longest streak
Hey im a total beginner and i tried alot here thats my best try so far Im looking for the longest Streak in a Int.List #how do i check for the longest streak? #[1,5,3,12,100,230,4,9] # __2__,____4_____,_2_ Streaks # my try was: intlist=[1,5,3,12,100,230,4,9] for streak in intlist: If streak=[0]<=[1]: Print("") Break: print(streak) # doesnt work, anyone an idea?
3 Respostas
+ 3
Save code and share link here..
In python, Identation is important factor. And is your code having autocapitalization? Or actual code?
your if condition has error. What is your condition about?
Mention lesson number Or link clearly.. Or detail description..
also which python course?
+ 1
my_int_list = [3,7,3,200,1100,7,9,12,18,20,4,8,5]
size = len(my_int_list)
streak = 0
max_streak = 0
for index in range(size):
x = my_int_list[index]
if index < size-1:
y = my_int_list[index+1]
if y >= x:
streak += 1
else:
streak = 0
max_streak = max(max_streak, streak)
print(max_streak)
+ 1
I found out. With the help of a friend. He didnt told me that the task was from leetcode