diff --git a/practice/raindrops/raindrops.py b/practice/raindrops/raindrops.py index f38f3b6..77f4fdd 100644 --- a/practice/raindrops/raindrops.py +++ b/practice/raindrops/raindrops.py @@ -1,2 +1,41 @@ def convert(number): - pass + """ + Convert a number into a string that contains raindrop sounds corresponding to certain potential factors. + + A factor is a number that evenly divides into another number, leaving no remainder. + The simplest way to test if one number is a factor of another is to use the modulo operation. + + The rules of raindrops are that if a given number: + + - has 3 as a factor, add 'Pling' to the result. + - has 5 as a factor, add 'Plang' to the result. + - has 7 as a factor, add 'Plong' to the result. + - does not have any of 3, 5, or 7 as a factor, the result should be the digits of the number. + + Args: + number (int): The number to be converted into a raindrop sound string. + + Returns: + str: The resulting raindrop sound string. + + Examples: + >>> convert(28) + 'Plong' + >>> convert(30) + 'PlingPlang' + >>> convert(34) + '34' + """ + sounds = [] + + if number % 3 == 0: + sounds.append('Pling') + if number % 5 == 0: + sounds.append('Plang') + if number % 7 == 0: + sounds.append('Plong') + + if len(sounds) == 0: + return str(number) + else: + return "".join(sounds) \ No newline at end of file