EXPERIMENT-11
Objective: To make a program to check if a substring is present in each string or not.
Source code:
string_list=["hello world","python programming","world of code","hello"]
substring="hello"
substring_present=[substring in string for string in string_list]
for i, string in enumerate(string_list):
if substring_present[i]:
print(f"substring '{substring}' is present in:'{string}'")
else:
print(f"substring '{substring}' is not present in: '{string}'")
Input and output:
Conclusion: This experiment successfully created a program that checks if a given substring
is present in each string of a provided string list.