رشته را بررسی کنید(Check String)

برای بررسی اینکه آیا عبارت یا کاراکتر خاصی در یک رشته وجود دارد، می‌توانیم از کلمات کلیدی استفاده کنیم.
در یا در نیست.




مثال


Check if the phrase "ain" is present in the following text:



txt = "The rain in Spain stays mainly in the plain"
x = "ain" in txt

print(x)






مثال


Check if the phrase "ain" is NOT present in the following text:



txt = "The rain in Spain stays mainly in the plain"
x = "ain"
not in txt

print(x)