Python Practice › String Programs › Program 59
Is a substring present?
Write a Python program to check whether a substring is present in a string.
Input
"I live in Pune", "I live "
Output
Yes
Approach
- Use
in.
Solution
text = "I live in Pune"print("Yes" if "I live " in text else "No")Output
Yes
Learn the concept
New to this topic? Read the lesson, then come back.