samedi 9 mai 2020

Why the if condition is passing each time?

Why the if statement passes the condition each time even if I am deliberately giving biased inputs to my code . Here is my code:

s1='efgh'
s2 = 'abcd'

for i in range(0,len(s1)):
    for j in range(1,len(s1)+1):
        if s1[i:j] in s2:
            print('YES')

It is printing 6 'YES'.

Aucun commentaire:

Enregistrer un commentaire