vendredi 3 septembre 2021

Figure out which part of or statement matches condition?

I have a fundamental and basic python question. I searched in the google but I couldn't find the answer. I am wondering when I use or in if condition is there any way to see which part of if condition is correct in the following example.

I have list : my= ['A','B','C']

if 'S' in my or 'T' in my or 'C' in my:
    print('yes')     # now I wanna know which one is correct. the answer here is `C`

Note : I know I can use for loop over elements of my to figure it out. I am wondering if there is a keycode for that or not.

Aucun commentaire:

Enregistrer un commentaire