The problem statement needs to make it clear what should happen, which is why people have been asking these kinds of questions because the person solving the problem isn't the person that determines this. There are all kinds of problems that could be posed involving identifying repeated numbers in a list. If I have a list that should not have any repeated values, a valid solution may do nothing more than return True as soon as the first occurrence of a repeated value is found and False only if no repeats are found. But another problem may require that a list of all values that occur more than once be returned. Yet another might want a count of how many different values are repeated. Many other possibilities exist.[1,2,1,2,1]
I know that I have to compare one element with the other element.
I wondered what should happen if a number repeats three times in list
So you don't need to wonder what should happen, you need to specify what you want to have happen (since you are the one defining the problem).