From 35162ddc57241d6824c57dd92ab61442302452a6 Mon Sep 17 00:00:00 2001 From: pigmal24 Date: Sun, 19 May 2024 17:24:24 +0900 Subject: [PATCH] 9.py --- YWCHOI/1to10/9.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 YWCHOI/1to10/9.py diff --git a/YWCHOI/1to10/9.py b/YWCHOI/1to10/9.py new file mode 100644 index 0000000..e37465d --- /dev/null +++ b/YWCHOI/1to10/9.py @@ -0,0 +1,12 @@ +def solution(num) : + digit = [] + while num > 0: + id = num % 2 + digit.append(str(id)) + num //= 2 + digit.reverse() + return ''.join(digit) #여기에서 좀 걸림 + +print(solution(10)) #반환값 : 1010 +print(solution(27)) #반환값 : 11011 +print(solution(12345)) #반환값 : 11000000111001 \ No newline at end of file