Python 3, 51 44 43 41 bytes
-7 thanks to loopy walt's suggestion to use *open
.
-1 thanks to xnor's suggestion to replace any(...)
with 1in ...
-2 thanks to dingledooper's suggestion of using str.find
instead of str.__eq__
0in map(str.find,*open(0))or print('yep')
Try it online!
This is a full program that takes input from stdin until an EOF (which we assume the user provides at the end of the second line) with open(0)
and map
s across the two strings by splatting (*
), calling str.find
on each pair of characters in turn. If 0
is in
the result (i.e. the characters are equal and so the index of the first in the second is 0
rather than -1
for "not found") then the right-hand clause of the or
is not evaluated, and so we don't print
.
My previous version, with xnor's and dingledooper's suggestions, at \$48\$, is interactive without the EOF faff:
0in map(str.find,input(),input())or print('yep')
You could save one more byte by printing to stderr instead of stdout by exiting the program early using exit
in place of print
.
A note to your son - this is not how I'd want someone in my team at work to write code :) - readability counts, a lot.
then
, whether you have anelse
or not. \$\endgroup\$