Notice
Recent Posts
Recent Comments
Link
Star_project
[인프런] 3.탐색&시뮬레이션(string, 1차원, 2차원 리스트 탐색 ) 2.숫자만추출 본문
2. 숫자만 추출
import sys
sys.stdin=open("pythonalgorithm/섹션 3/2. 숫자만 추출/in1.txt","rt")
a=input()
res=cnt=0
for i in a:
if i.isdecimal():
res=res*10+int(i)
print(res)
for i in range(1,res+1):
if res%i==0:
cnt+=1
print(cnt)
- isdecimal()
Definition and Usage
The isdecimal() method returns True if all the characters are decimals (0-9).
This method is used on unicode objects.
Python String isdecimal() Method
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
www.w3schools.com
- 약수의 개수를 구할 때 for 범위는 range(1, 해당값+1)
'코딩테스트 > Python' 카테고리의 다른 글
[인프런] 3.탐색&시뮬레이션(string, 1차원, 2차원 리스트 탐색 ) 1.회문 문자열 검사 (0) | 2022.07.12 |
---|---|
[인프런] 2. 자료구조와 알고리즘 입문 10.점수 계산 (0) | 2022.07.12 |
[인프런] 2. 자료구조와 알고리즘 입문 9.주사위 게임 (0) | 2022.07.12 |
[인프런] 2. 자료구조와 알고리즘 입문 8. 뒤집은 소수 (0) | 2022.07.12 |
[프로그래머스] 자릿수 더하기 (0) | 2022.07.11 |