Why this is showing error ? even though it seems all syntax is correct?

Put single ticks around the items being compared: '[' instead of "[". That way you are comparing char to char instead of char to a string