There are some ways in Python to analyze string.
- substring in s
Returns True if the string s contains substring and False otherwise.
if "-" is not in name:
...
- s.count(substring)
Returns the number of non-overlapping occurrences of substring in s.
- s.endswith(substring)
Returns True if the string s ends with the substring and False otherwise.
- s.startswith(substring)
Returns True if the string s starts with the substring and False otherwise.
- s.find(substring)
Returns the lowest index in the string s where substring begins, or –1 if substring is not found.
'python' 카테고리의 다른 글
Terminating a Program (프로그램 종료) (0) | 2025.01.12 |
---|---|
[baekjoon] 2563번 색종이 Python (0) | 2023.10.14 |
[baekjoon] 10789번 세로읽기 Python (1) | 2023.10.14 |
[programmers] 문자열 여러번 뒤집기 (python) (8) | 2023.10.11 |
[python] tkinter miles km converter / tkinter 마일 킬로미터 변환기 (3) | 2023.10.10 |