Byungjin
0
Q:

find string in string python

fullstring = "StackAbuse"
substring = "tack"

if substring in fullstring:
    print "Found!"
else:
    print "Not found!"
4
>>> str = "Messi is the best soccer player"
>>> "soccer" in str
True
>>> "football" in str
False
6
word = 'geeks for geeks'
  
# returns first occurrence of Substring 
result = word.find('geeks') 
print ("Substring 'geeks' found at index:", result ) 
  
result = word.find('for') 
print ("Substring 'for ' found at index:", result ) 
  
# How to use find() 
if (word.find('pawan') != -1): 
    print ("Contains given substring ") 
else: 
    print ("Doesn't contains given substring") 
2
string.find(substring)
0
str.find(str, beg=0, end=len(string))
# find looks from 'beg' to 'end' after the str
1
s=s[start:end]
-1

New to Communities?

Join the community