Why is ‘a’ in (‘abc’) True while ‘a’ in [‘abc’] is False?

('abc') is the same as 'abc'. 'abc' contains the substring 'a', hence 'a' in 'abc' == True.

If you want the tuple instead, you need to write ('abc', ).

['abc'] is a list (containing a single element, the string 'abc'). 'a' is not a member of this list, so 'a' in ['abc'] == False

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)