Skip to content
Code ReadingHow Many Different Values?
Break the Code

How Many Different Values?

Write a list for which this function gives the wrong answer.
1def count_distinct(values):
2 count = 1
3 for i in range(1, len(values)):
4 if values[i] != values[i - 1]:
5 count += 1
6 return count