0
What is the code to check wether the string is substring of given string?
6 Réponses
+ 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).
+ 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)
+ 1
Oh...its really easy ...thanx😊Kishalaya Saha
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?
0
Ok
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!😊