반응형
Write function parse_float which takes a string/list and returns a number or 'none' if conversion is not possible.
Solution:
def parse_float(string: str) -> float | None:
try:
return float(string)
except (ValueError, TypeError):
return None
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0205. pick a set of first elements (0) | 2023.02.05 |
---|---|
0204. Filter the number (0) | 2023.02.04 |
0202. Beginner Series #1 School Paperwork (0) | 2023.02.02 |
0201. Who ate the cookie? (0) | 2023.02.01 |
0131. You only need one - Beginner (0) | 2023.02.01 |