Python Strings · Question 5 · Easy

The in operator tests two substrings of a city name. What does this print?

city = "Bangalore"
print("lo" in city, "Lo" in city)
  1. True True
  2. False False
  3. True False
  4. False True
Answer and explanation

Answer: C. True False

Explanation: in checks whether the left string occurs anywhere inside the right one, and "lo" is present in "Bangalore". The test is case-sensitive, so "Lo" with a capital L is not found.

Previous: Which string method removes whitespace from both ends of a string? · Next: An f-string is used to report Asha's marks. What exactly is printed?

Practise python strings

Try a fresh set of python strings questions with an explanation after every answer, free and without signing up: Python Strings practice. Or sit a full placement mock test.

More python strings questions

More python practice

Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files · Built-ins & Standard Library

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge