本文介绍了比较两组中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想比较两个不同组中的值,以测试任一组中的任何一个位置是否共享相同的值(例如,如果第三个 $ b每组的$ b元素是''a'',然后测试失败)。 我有这个: def test_sets (original_set,trans_letters): 用于zip中的对(original_set,trans_letters): 如果对[0] ==对[1]: 返回False 返回True zip()是我想到的第一件事,但我想知道是否有 其他一些方法,也许是一个实际上做这种内置的测试。 谢谢。I''d like to compare the values in two different sets to test if any ofthe positions in either set share the same value (e.g., if the thirdelement of each set is an ''a'', then the test fails).I have this:def test_sets(original_set, trans_letters):for pair in zip(original_set, trans_letters):if pair[0] == pair[1]:return Falsereturn Truezip() was the first thing I thought of, but I was wondering if there''ssome other way to do it, perhaps a builtin that actually does this kindof testing.Thanks.推荐答案 这篇关于比较两组中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-11 16:33