+ 1

Why "if condition" runs everytime in both true/false condition

In the code Line Number :17 https://code.sololearn.com/cw54rcNwRcBB/?ref=app

17th Jun 2021, 7:04 PM
Amit Biswas
Amit Biswas - avatar
4 Antworten
+ 3
try if found==False: P.S its happening because of scoping the "found variable" is inside for loop so outside of for loop its just undefined variable. and invert it you get true all the time ( swap line 11 and 12 .)
17th Jun 2021, 7:08 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 3
Amit Biswas i have edited my answer . because of single space indentation i wasn't able to read clearly .
17th Jun 2021, 7:12 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 2
Not working....
17th Jun 2021, 7:10 PM
Amit Biswas
Amit Biswas - avatar
+ 2
Thanks....I have fixed it
17th Jun 2021, 7:16 PM
Amit Biswas
Amit Biswas - avatar