Python 49 45 18 22 15 14
##( + 3 if string variables are considered)##
( + 3 if string variables are considered)
print{a:0,b:1}[a]
The string should be hard coded at the two occurrences of a
and one occurrence of b
surrounded by quotes.
a
and b
should be pre-initialized to the strings.
Python shell, 9
##( + 3 if string variables are considered) ##
( + 3 if string variables are considered)
{a:0,b:1}[a]
Output in shell
>>> a = 'string'
>>> b = 'string'
>>> {a:0,b:1}[a]
1
>>> a = 'string'
>>> b = 'stringgg'
>>> {a:0,b:1}[a]
0
>>> {'string':0,'string':1}['string']
1
>>> {'stringggg':0,'string':1}['stringggg']
0
>>>
Explanation
Creates a dict(hash table) with the key of first and second string. If second string is the same, the value of first is replaced by that of second. Finally, we print the value of first key.
EDIT: OP allowed 0/1 instead of False/True as well as using pre-initialized variables.