add an octal_to_binary converter#8940
Closed
RayaneQH wants to merge 1 commit intoTheAlgorithms:masterfrom
RayaneQH:add_octal_to_binary_converter
Closed
add an octal_to_binary converter#8940RayaneQH wants to merge 1 commit intoTheAlgorithms:masterfrom RayaneQH:add_octal_to_binary_converter
RayaneQH wants to merge 1 commit intoTheAlgorithms:masterfrom
RayaneQH:add_octal_to_binary_converter
Conversation
tianyizheng02
requested changes
Aug 12, 2023
Comment on lines
+3
to
+8
| >>> octal_to_binary("17") | ||
| '1111' | ||
| >>> octal_to_binary("52523") | ||
| '101010101010011' | ||
| >>> octal_to_binary("532.51") | ||
| '101011010.101001' |
Contributor
There was a problem hiding this comment.
These doctests should go inside a docstring within the function, not at the top of the file.
| """ | ||
|
|
||
|
|
||
| from operator import index |
Contributor
There was a problem hiding this comment.
Suggested change
| from operator import index |
This import is never used, and it's causing pre-commit to fail.
Comment on lines
+36
to
+40
| if binary_string == "": | ||
| for char in dict_of_octal_to_binary[i]: | ||
| if char != "0" or indexl >= 1: | ||
| binary_string += char | ||
| indexl += 1 |
Contributor
There was a problem hiding this comment.
Instead of having a special case for handling 0's at the start of the binary string, why not just append to the binary string as normal and handle the starting 0's at the very end?
| "7": "111", | ||
| } | ||
| indexl = 0 | ||
| for i in octal_string: |
Contributor
There was a problem hiding this comment.
Can we do this with a comprehension instead of manually appending to a string?
Contributor
|
Closing in favor of #8949 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change:
Checklist: