2021年2月4日星期四

check if all the values for different keys are the same

I want to return true if all the values in dict for different keys is same else false:

for example: {1: [1, 1, 1], 2: [1, 1, 1], 3: [1, 1, 1]}) this should return true: {1: [1, 1, 1], 2: [1, 1, 1], 3: [1, 2, 1]}) this should return false.

I tried the following but it didnt work.

        # for i in range(len(votes_grid[0])):          #     isTie = any(v == i for v in columnTable.values())          #also tried                isTie = all(v == i for v in columnTable.values())  
https://stackoverflow.com/questions/66056590/check-if-all-the-values-for-different-keys-are-the-same February 05, 2021 at 10:04AM

没有评论:

发表评论