발생하는 문제 및 실행환경
문자열이 "hello"로 시작하는지 알아내러고 할 때 저는 보통 slicer를 써서 하는데 이것 보다 더 쉬운 방법이 있는지 궁금합니다.
소스코드
mystring = "hello python world!"
if mystring[:len("hello")] == "hello":
print("yes!")
문자열이 "hello"로 시작하는지 알아내러고 할 때 저는 보통 slicer를 써서 하는데 이것 보다 더 쉬운 방법이 있는지 궁금합니다.
mystring = "hello python world!"
if mystring[:len("hello")] == "hello":
print("yes!")