It is necessary to check whether 3 identical elements of the array go in a row. An error occurs in if item == value: because value is not a local variable. I tried to make it local, but then my algorithm did not work, which does not work in function
packofCards = ['Черви','Черви','Черви'] value = packofCards[0] def shuffle(packofCards): counter = 0 for index, item in enumerate(packofCards): if item == value: value = item counter += 1 if counter >=3: return 0 else: return 'Нет трех идущих подряд карт одной масти' print(shuffle(packofCards))