0

What is the code to check wether the string is substring of given string?

3rd May 2020, 2:33 AM
Anupriya Mishra
Anupriya Mishra - avatar
6 odpowiedzi
+ 2
It's because word contains ["fam"], that is the list containing "fam", as an element. If you said print(["fam"] in word), you should have gotten True. Your original question is somewhat different from the one in the comment. It may be a good idea to modify it so they mean the same thing. Also, please add the language tag (python).
3rd May 2020, 3:24 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 2
Okay, checking whether a string is a substring of a given string is really easy in Python. It is just like what you did for a list: given_string = "pinapple" substring = "app" print(substring in given_string)
3rd May 2020, 3:36 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
Oh...its really easy ...thanx😊Kishalaya Saha
3rd May 2020, 9:20 AM
Anupriya Mishra
Anupriya Mishra - avatar
0
Why its not showing Word=[ "sam",["fam"],"till"] Print("sam" in word ) Print ("fam" in word ) Output: True False My query is why it is showing false when i m trying to print fam?
3rd May 2020, 2:35 AM
Anupriya Mishra
Anupriya Mishra - avatar
0
Ok
3rd May 2020, 3:26 AM
Anupriya Mishra
Anupriya Mishra - avatar
0
Thanx Kishalaya Saha .... actually i wanted to ask both qestions! So thats why i have written one of them in comment if it is not a suitable method i will modify it!😊
3rd May 2020, 3:31 AM
Anupriya Mishra
Anupriya Mishra - avatar