1.

To check whether string s1 contains another string s2, use ________(a) s1.__contains__(s2)(b) s2 in s1(c) s1.contains(s2)(d) si.in(s2)The question was asked in an interview for job.Question is taken from Strings in section Strings of Python

Answer»

Right choice is (a) s1.__contains__(S2)

BEST EXPLANATION: s2 in s1 works in the same WAY as calling the SPECIAL function __contains__ .



Discussion

No Comment Found

Related InterviewSolutions