如何比较两个以上变量的值

2024-04-29 10:31:24 发布

您现在位置:Python中文网/ 问答频道 /正文

for word, sentence in tup:
    while True:
        x, y, z = random.sample(range(words_count), 3)
        if list[x] != list[y] != list[z]:
            aya_index += 1
            print('breaking after success')
            break
        else:
            print('continuing as there are similar words')
            continue
    if aya_index > words_count - 1:
        print('breaking after finishing')
        break

如您所见,上面的代码应该在tup上循环,并且仅在这三个变量不相等时增加aya_索引,问题是,这是如何在变量之间进行比较,还是有更有效的方法


Tags: inforindexifcountsentencelistword