Skip to content

Commit 103d7c4

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f992b5e commit 103d7c4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

bit_manipulation/binary_count_trailing_zeros.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ def binary_count_trailing_zeros(a: int) -> int:
4444
doctest.testmod()
4545

4646

47-
#counting number of 0s and 1s in a binary number
47+
# counting number of 0s and 1s in a binary number
4848
def count_zeros_and_ones(binary_number):
4949
# Convert the binary number to a string if it's not already
5050
binary_str = str(binary_number)
51-
52-
count_zeros = binary_str.count('0')
53-
count_ones = binary_str.count('1')
54-
51+
52+
count_zeros = binary_str.count("0")
53+
count_ones = binary_str.count("1")
54+
5555
return count_zeros, count_ones
5656

57+
5758
# Get user input
5859
binary_number = input("Enter a binary number: ")
5960

6061
# Validate input
61-
if all(bit in '01' for bit in binary_number):
62+
if all(bit in "01" for bit in binary_number):
6263
zeros, ones = count_zeros_and_ones(binary_number)
6364
print(f"Number of 0s: {zeros}, Number of 1s: {ones}")
6465
else:
6566
print("Invalid input! Please enter a valid binary number.")
66-

0 commit comments

Comments
 (0)