skrf.util.has_duplicate_value

skrf.util.has_duplicate_value(value, values, index)[source]

Check if there is another value of the current index in the list.

Parameters:
  • value (Any) – any value in a list

  • values (Iterable) – the iterable containing the values

  • index (int) – the index of the current item we are checking for.

Returns:

index – returns None if no duplicate found, or the index of the first found duplicate

Return type:

bool or int

Examples

>>> rf.has_duplicate_value(0, [1, 2, 0, 3, 0], -1)  # -> 2
>>> rf.has_duplicate_value(0, [1, 2, 0, 3, 0], 2)  # -> 4
>>> rf.has_duplicate_value(3, [1, 2, 0, 3, 0], 0)  # -> 3
>>> rf.has_duplicate_value(3, [1, 2, 0, 3, 0], 3)  # -> False