8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a469aab + 78ab31e commit 02ffd4dCopy full SHA for 02ffd4d
strings/substring-check.py
@@ -1,12 +1,8 @@
1
-# function to check if small string is
2
-# there in big string
3
-def check(string, sub_str):
4
- if (string.find(sub_str) == -1):
5
- print("NO")
6
- else:
7
- print("YES")
8
-
9
-# driver code
10
-string = "" #Enter string
11
-sub_str ="" #Enter sub string
12
-check(string, sub_str)
+def substring_check(string, sub_str):
+ return sub_str in string
+
+string = "Hello everyone"
+sub_str_present ="llo e"
+sub_str_absent ="abcd"
+print(substring_check(string, sub_str_present)) # True
+print(substring_check(string, sub_str_absent)) # False
0 commit comments