Computer Science, asked by Vishal18071, 10 months ago

Write the output of the following code.
# !/usr/bin/py thon
str1 = "this is string example… ,wow!!!"\
str2 = "exam"
print strl.find(str2)
print strl.find(str2,10)
print strl.find(str2, 40)

Answers

Answered by letmeanswer12
2

Output is 15, 15,-1

Explanation:

  • The first print is to find the index value of string 'exam' in the string "this is string example… ,wow!!!". The string 'exam' matches at the index 15 in "this is string example… ,wow!!!", so the output is 15.
  • The second print is to find the index value of string 'exam' in the string "this is string example… ,wow!!!" from the 10th position. The string 'exam' matches at the index 15 in "this is string example… ,wow!!!", so the output is 15.
  • The third print is to find the index value of string 'exam' in the string "this is string example… ,wow!!!" from the 40th position. The string 'exam' does not match after the 40th index in "this is string example… ,wow!!!", so the output is -1.

Output :

  • 15
  • 15
  • -1

Similar questions