Added two optimized pythonic functions and removed unnecessary semicolons. #66
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.
Hello, I have proposed the following changes to include optimized code and resemble pythonic syntax in the strings section.
Added function
is_palindrome_pythonic()
instrings/is_palindrome.py
file. Used list comprehension to store alphanumeric characters in a list, then compared it with its reverse (using the pythonic way) and finally return the result of the comparison.Added function
add_binary_pythonic()
instrings/add_binary.py
file.a
is concatenated with a prefix'0b'
. This string (e.g. '0b1101') represents binary number 1101 in python.'0b' + a
int()
function of python with second parameter as 2, which represents the base of the first parameter string (binary = base 2).int('0b' + a, 2)
int()
function converts the string (e.g. '0b1101') to the decimal value and stores in the variabledecimal_a
. (e.g. '0b1101' converts to 13)decimal_a = int('0b' + a, 2)
b
.decimal_b = int('0b' + b, 2)
bin()
function.bin(decimal_a + decimal_b)
'0b'
(e.g. '0b10110'), which is sliced to keep the part after'0b'
.[2:]
Removed semicolons in
strings/int_to_roman.py
file to resemble python syntax.Any suggestions and feedback are welcomed.