00:02
So in this problem, we are supposed to ask the user for a list of integers, and then we are supposed to check if the list of the numbers has four consecutive such numbers which are equal in value.
00:19
And if this is the case, we check and say that there is four consecutive numbers.
00:25
And if that's not the case, then we return a message saying there are no four consecutive numbers.
00:30
So we must check for four consecutive number.
00:34
It could be anything, it could be any location, any number, but there must be four and must be consecutive equal numbers.
00:41
So first we ask the user to enter a list and that is this portion of the program.
00:47
So we ask them to enter lists separate by commas and then we use the input function to store it as a list in numps.
00:56
And then we know that numps, we can split the string based on any character and we split it based on comma.
01:04
So that will split the continuous string into segments or elements of list, which will still be characters but they will now be separated and not a single string.
01:17
And then we basically take all these elements of this string or the list now that is, now this numbs is a list.
01:26
We take all the values n in that list and if check if it's empty or not because sometimes what somebody can do is somebody can do this leave an empty thing or they can also do two commas in three and four.
01:43
So this will give you an empty character.
01:46
So there is no number associated with this.
01:48
So we must not take this as a number.
01:51
So to avoid this we check if the list is or the character is empty.
01:56
If it is not empty, then we append a empty list with the eval output of that character because we want to convert it into an integer number and that's what eval function does.
02:08
So with this we can make convert an input into a list of numbers.
02:13
So having done that, we go to the next part of the program and this is the is consecutive portion of the function.
02:22
So it's called is consecutive 4 and what it does is the following.
02:25
Let me just draw the logic on the right side.
02:27
So for example, you have some numbers which are and so on.
02:35
So these could be four consecutive numbers which are equal.
02:37
I'm just showing positions rather than the values.
02:41
So what i want is that i want to take one number and check it against the next three numbers.
02:48
If they're equal.
02:50
And if not, then you go to the next number, check it against the next three numbers.
02:54
And then if that's not true, then go to the third number, check it against the next three numbers.
02:59
So that's how i want to keep going.
03:00
And i want to finally end up, let's say i have till here.
03:10
So i want to go to g check for three more numbers.
03:14
And then i don't want to check for h -i -n -j because they are numbers which don't have consecutive three numbers anymore.
03:22
H only has two more numbers.
03:23
I only has one number on the right side.
03:25
And nothing to the left matters because we have already coming from the left in a sequence fashion.
03:28
So there's no need to check on the left.
03:29
We only check to the right.
03:31
Because if h had something equal on the left side, g, f or g would have checked for that.
03:37
So that's how we go.
03:39
So what we do is we go from zero index all the way to, let's say this index is n.
03:45
Or let's say the length of the list is n.
03:48
We go to n minus 3.
03:55
So we should go to n minus 4 actually.
03:58
But since we're using a range function over here, the range function already goes to n minus 3 minus 1...