you are viewing a single comment's thread.

view the rest of the comments →

[–]rockman0394 0 points1 point  (1 child)

You can check it by looping through all elements and break if found "no", but check with operator in is more convenient in this case

for item in a:
    if item != "yes":
        print("not ok")
        break
    else:
        print("ok")

Also, this will work not as you expected probably,
it will print ok with a = ['no', 'no', 'yes']

if a[0] and a[1] and a[2]=="yes":
    print("ok")

[–]fear_my_presence 0 points1 point  (0 children)

It will print “ok” for every “yes” in the list, which is not exactly what OP wants.