Python

[Python] find(), index() 다른점

insub4067 2021. 10. 25. 16:28
str = "Hello World"

print(str.index("Hi")) 
#에러를 반환

print(str.find("Hi"))
#false를 의미하는 -1을 반환

에러를 반환할 경우 다음 소스를 실행하지 않는다