summaryrefslogtreecommitdiff
path: root/comp/work/42/test
diff options
context:
space:
mode:
Diffstat (limited to 'comp/work/42/test')
-rw-r--r--comp/work/42/test/test.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/comp/work/42/test/test.py b/comp/work/42/test/test.py
new file mode 100644
index 0000000..4e70d92
--- /dev/null
+++ b/comp/work/42/test/test.py
@@ -0,0 +1,21 @@
+def tostring(list):
+ string = ""
+ for i in list:
+ string += str(i)
+ print(string)
+
+def getbin(n):
+ out = []
+ while (n >= 1):
+ out.append(n % 2)
+ n = int(n / 2)
+
+ out.reverse()
+ return out
+
+def tobin(n):
+ raw = getbin(n)
+ tostring(raw)
+
+n = int(input("what number would you like to convert: "))
+tobin(n)