# String pattern matching
#coding:utf-8

txt = input("Enter text:")
pattern = input("Enter the pattern to look for: ")

#4 types of string search modules
ans1 = txt.find(pattern) #Search from the left of txt
ans2 = txt.rfind(pattern) #Search from the right of txt
ans3 = txt.index(pattern)
ans4 = txt.rindex(pattern)

ans = ans1

if ans == -1:
    print("Not Found!")
else:
    print(pattern + "found." + txt + "in" + str(ans) + "th.")

実行結果