From 8154511e46a4c29539c189b925c4c0596859fd08 Mon Sep 17 00:00:00 2001 From: shellhub Date: Thu, 24 Sep 2020 17:24:08 +0800 Subject: [PATCH 1/2] updated reversed words --- strings/reverse_words.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/strings/reverse_words.py b/strings/reverse_words.py index 8ab060fe1d24..504c1c2089dd 100644 --- a/strings/reverse_words.py +++ b/strings/reverse_words.py @@ -1,18 +1,15 @@ -# Created by sarathkaul on 18/11/19 -# Edited by farnswj1 on 4/4/20 - - def reverse_words(input_str: str) -> str: """ Reverses words in a given string - >>> sentence = "I love Python" - >>> reverse_words(sentence) == " ".join(sentence.split()[::-1]) - True - >>> reverse_words(sentence) + >>> reverse_words("I love Python") 'Python love I' + >>> reverse_words("I Love Python") + 'Python Love I' """ - return " ".join(reversed(input_str.split(" "))) + return " ".join(input_str.split()[::-1]) if __name__ == "__main__": - print(reverse_words("INPUT STRING")) + import doctest + + doctest.testmod() From b1e0efe8aa3980e0201ebcc9bbeea3d16e44d3e3 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 24 Sep 2020 09:25:46 +0000 Subject: [PATCH 2/2] fixup! Format Python code with psf/black push --- bit_manipulation/binary_and_operator.py | 1 + bit_manipulation/binary_xor_operator.py | 1 + 2 files changed, 2 insertions(+) diff --git a/bit_manipulation/binary_and_operator.py b/bit_manipulation/binary_and_operator.py index e5dffe3e31d2..f1b910f8cc9b 100644 --- a/bit_manipulation/binary_and_operator.py +++ b/bit_manipulation/binary_and_operator.py @@ -1,5 +1,6 @@ # https://www.tutorialspoint.com/python3/bitwise_operators_example.htm + def binary_and(a: int, b: int): """ Take in 2 integers, convert them to binary, diff --git a/bit_manipulation/binary_xor_operator.py b/bit_manipulation/binary_xor_operator.py index 32a8f272116e..0edf2ba6606d 100644 --- a/bit_manipulation/binary_xor_operator.py +++ b/bit_manipulation/binary_xor_operator.py @@ -1,5 +1,6 @@ # https://www.tutorialspoint.com/python3/bitwise_operators_example.htm + def binary_xor(a: int, b: int): """ Take in 2 integers, convert them to binary,