From 02653ab40d93fb7e6d07edb747fe0e07c5d60c74 Mon Sep 17 00:00:00 2001 From: thing1 Date: Thu, 30 Jan 2025 12:49:01 +0000 Subject: did many new things --- comp/work/42/test/test.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 comp/work/42/test/test.py (limited to 'comp/work/42/test') 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) -- cgit v1.2.3