find a character in string python code example
Example 1: how to find the location of a character in a string in python
>>> myString = 'Position of a character'
>>> myString.find('s')
2
>>> myString.find('x')
-1
Example 2: how to search for a specific character in a part of a python string
myString = "God is good"
if "o" in myString[0:4]
print("Working! There is an 'O' in between the G and D of God.")
Example 3: python find string in string
string.find(substring)
Example 4: find character in python
banana = "banana"
banana.find("a")
banana.find("a",2)