📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!

  • google app store apple app store
  • âś–

      Question

      What is the outpur of the following part of python

      program? s="india" 1=0 for x in s: if(X!="i"): 1=1+1 else: pass print(1)
      A 1 Correct Answer Incorrect Answer
      B 5 Correct Answer Incorrect Answer
      C 6 Correct Answer Incorrect Answer
      D 3 Correct Answer Incorrect Answer

      Solution

      • String "india" → characters = i, n, d, i, a
      • Condition if(x != "i") counts all characters except "i" .
      • "n" , "d" , "a" satisfy condition → count = 3.
      • Output = 3 .
      • Why Others are Wrong:
        • 1: Wrong, only counts one.
        • 5: Would mean all counted.
        • 6: Impossible (string length is 5).

      Practice Next

      Relevant for Exams:

      ask-question