I am writing a program in which a user inputs values into a list until the want to end it and the program will tell the user the longest streak of numbers they entered. For example, is the user inputted 7,7,7,6,6,4,end the would get the output: your longest streak was 3. As 7 was entered 3 times in a row.
So far I have this and it seems to not want to ever end the current run so if i enter 7,7,7,6,6,6,6,5,4 it will tell me the longest streak is 7 like it is continuing the streak from the 7 being entered. This is what i have:
mylist = []
run = 1
currentrun = 1
number = input('enter a number: ')
mylist.append(number)
while number != 'end' :
number = input ('enter a number: ')
mylist.append(number)
for i in range (len(mylist)):
if mylist[i] == mylist[i-1] and mylist[i] == mylist[i+1] :
currentrun = currentrun + 1
else:
currentrun = 0
print (currentrun)
if currentrun > run:
run = currentrun
print (mylist)
print ('Your longest run was' ,run)
Any help is greatly appreciated.