나는 이렇게 학습한다/Algorithm & SQL
0912. Fake Binary
daco2020
2022. 9. 13. 01:04
Given a string of digits, you should replace any digit below 5 with '0' and any digit 5 and above with '1'. Return the resulting string.
Note: input will never be an empty string
Solution:
def fake_bin(x): return ''.join(str(int(i) >= 5 and 1 or 0) for i in x)