Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 강원도속초맛집
- c언어문자열
- pipenv
- 부스트코스
- richtext
- 가상환경
- 정렬알고리즘
- 아스키코드
- 자바
- popupmenubutton
- 노마드코더
- removetooltip
- python3
- 장고
- BeautifulSoup
- FLUTTER
- 상속
- 추상클래스
- 남양주맛집
- 포인터
- Python
- 컴퓨터과학
- JavaScript
- Django
- DOM
- 속초여행
- 알고리즘
- 성수동카페
- 건대입구맛집
- 코딩독학
Archives
- Today
- Total
YUYANE
Python/ HackerRank Detect Floating 본문
문제
www.hackerrank.com/challenges/introduction-to-regex/problem?h_r=internal-search
Detect Floating Point Number | HackerRank
Validate a floating point number using the regular expression module for Python.
www.hackerrank.com
해결 코드
T = int(input())
nums = []
def detect(a):
if '.' in a:
idx = a.find('.')
try:
float(a)
if len(a) > idx:
value = a[idx+1]
try:
int(value)
return True
except:
return False
except:
return False
else:
return False
for i in range(T):
num = input()
nums.append(num)
for i in range(len(nums)):
print(detect(nums[i]))
겪었던 어려움
Python/ 문자열에서 특정 인덱스 값 다음의 문자를 찾을 때 유의
전체 코드 T = int(input()) nums = [] def detect(a): if '.' in a: idx = a.find('.') try: float(a) return a[idx+1] except: return False else: return False for i in range(T): num = input() nums.append(..
1y9u9j2in.tistory.com
'Programming Theory > Algorithm' 카테고리의 다른 글
알고리즘 / 계수 정렬 (0) | 2021.01.25 |
---|---|
알고리즘 / 삽입 정렬 (0) | 2021.01.23 |
알고리즘 / 선택 정렬 (0) | 2021.01.22 |
Python/ HackerRank Find the Runner-Up Score! (0) | 2021.01.11 |
JAVA / charAt() (백준 11720 자바) (0) | 2020.11.26 |
Comments