From 73dde268f8d1e772704c14ad8d16001b392d4b77 Mon Sep 17 00:00:00 2001 From: Natalia Date: Tue, 1 Oct 2024 18:48:25 +0200 Subject: [PATCH] solution/m1-015 --- projects/015-parity-bits/python/main.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/projects/015-parity-bits/python/main.py b/projects/015-parity-bits/python/main.py index e69de29..cf91dea 100644 --- a/projects/015-parity-bits/python/main.py +++ b/projects/015-parity-bits/python/main.py @@ -0,0 +1,14 @@ +string=input("Enter a string of 8 bits: ") + +while string!="": + if len(string)==8: + one_bit_number=string.count("1") + if one_bit_number%2==0: + print("The parity bit is 0") + else: + print("The parity bit is 1") + + else: + print("You have entered something other than 8 bits") + + string=input("Enter a string of 8 bits: ") \ No newline at end of file