Horje
Python String Index() Code Example
Python String Index()
myStr = "py py py py"
print(myStr.find("js"))
print(myStr.index("js"))
Python String Index()
myStr = "py py py py"
print(myStr.find("js"))
print(myStr.index("js"))
Python String Index()
myStr = "py py py py"
print(myStr.find("js"))
print(myStr.index("js"))
Python String Index()
myStr = "py py py py"
print(myStr.find("js"))
print(myStr.index("js"))


## OUTPUT:

-1
Traceback (most recent call last):
  File "D:\Programming\python\article\find.py", line 38, in <module>
    print(myStr.index("js"))
ValueError: substring not found
python string index of
sentence = 'Python programming is fun.'

result = sentence.index('is fun')
print("Substring 'is fun':", result)

result = sentence.index('Java')
print("Substring 'Java':", result)




Python

Related
python call function that need args with decorator Code Example python call function that need args with decorator Code Example
how to Write the regular expression that will match all non-digit characters of a string. Code Example how to Write the regular expression that will match all non-digit characters of a string. Code Example
class dog_years:   years = 0   __      fido=Dog() fido.years=3 print(fido.dog_years()) Code Example class dog_years: years = 0 __ fido=Dog() fido.years=3 print(fido.dog_years()) Code Example
Python >>> import this Code Example Python >>> import this Code Example
first 2 terms Code Example first 2 terms Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7