Python Practice › String Programs › Program 59

Is a substring present?

EasyString Programs · 59 of 106

Write a Python program to check whether a substring is present in a string.

Advertisement
Input
"I live in Pune", "I live "
Output
Yes

Approach

  1. Use in.

Solution

Python
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.

More string programs

← All 106 String Programs

Leave a Comment