From ffe5dc6f31451e0e116fb910a19883e0170b4ccf Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Tue, 11 Nov 2025 20:26:08 +0000 Subject: [PATCH] [Sync Iteration] python/raindrops/1 --- solutions/python/raindrops/1/raindrops.py | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 solutions/python/raindrops/1/raindrops.py diff --git a/solutions/python/raindrops/1/raindrops.py b/solutions/python/raindrops/1/raindrops.py new file mode 100644 index 0000000..3783e0a --- /dev/null +++ b/solutions/python/raindrops/1/raindrops.py @@ -0,0 +1,28 @@ +def convert(number): + """ + Converts a number into its corresponding raindrop sounds (Pling, Plang, Plong) + based on divisibility by 3, 5, and 7. + """ + + # Start with an empty string to accumulate the sounds. + raindrops = "" + + # Check for divisibility by 3. + # We use independent 'if' statements so we can add multiple sounds. + if number % 3 == 0: + raindrops += "Pling" + + # Check for divisibility by 5. + if number % 5 == 0: + raindrops += "Plang" + + # Check for divisibility by 7. + if number % 7 == 0: + raindrops += "Plong" + + # If the string is empty, it means the number was not divisible by 3, 5, or 7. + # In that case, we return the original number as a string. + if not raindrops: + return str(number) + else: + return raindrops \ No newline at end of file