Robotics & Artificial Intelligence

What will be the output of the code given below?

st = "This is a test String"
v = st.count("s")
print(v)
  1. 1
  2. 2
  3. 3
  4. 4

Python String Manipulation

1 Like

Answer

3

Reason — The count("s") function counts only lowercase occurrences of the character "s" in the string. In the string "This is a test String", the lowercase letter s appears three times. The capital S is not counted because Python is case-sensitive.

Answered By

1 Like


Related Questions