如果一列中的所有值都相同,如何创建返回 true 的方法。
myListtrue = [['SomeVal', 'Val',True],
['SomeVal', 'blah', True]] #Want this list to return true
#because the third column in the list
#are the same values.
myListfalse = [['SomeVal', 'Val',False],
['SomeVal', 'blah', True]] #Want this list to return False
#because the third column in the list
#is not the same value
same_value(myListtrue) # return true
same_value(myListfalse) # return false
方法头示例:
def same_value(Items):
#statements here
# return true if items have the same value in the third column.