1fullstring = "StackAbuse"
2substring = "tack"
3
4if fullstring.find(substring) != -1:
5 print "Found!"
6else:
7 print "Not found!"
8
1#look like: your_srting % values
2 #when:
3 #your_string = "any king of character %format"
4 #type(value) = tuple
5# A falg can be added between the % and the format
6
7#Exemple:
8
9print("there is %d ducks in the lake" % 34) #>>> there is 34 duck in the lake
10
11# Or
12
13your_string = "%d of the %d ducks are ducklings"
14values = (12, 32)
15print(your_string % values) #>>> 12 of the 34 ducks are ducklings
16
17Formaters are:
18 # Strings
19 %s to display as string (and do str(value) if needed)
20 #Integers
21 %i to display in default int form
22 %d to display as a decimal integer
23 %x to display as an hexadecimal intedger (with lettre in lowercase)
24 %X to display as an hexadecimal intedger (with lettre in uppercase)
25 %o to display as an octal integer
26 %u to display as an unsigned integer
27 %c to display in ascii (process "chr(value)")
28 #Floats
29 %f to display in default float form
30 %e to display in scientific writing (with a lowercase e to expess exponent)
31 %E to display in scientific writing (with an uppercase E to expess exponent)
32 %g to display as an floating exponent
1>>> str = "Messi is the best soccer player"
2>>> "soccer" in str
3True
4>>> "football" in str
5False
1def find_string(string,sub_string):
2 return string.find(sub_string)
3#.find() also accounts for multiple occurence of the substring in the given string
1def is_value_in_string(value: str, the_string: str):
2 return value in the_string.lower()