exercism

Exercism solutions.
git clone git://code.dwrz.net/exercism
Log | Files | Refs

raindrops.py (581B)


      1 """This module provides a function to convert a number into a string that
      2  contains raindrop sounds corresponding to certain potential factors."""
      3 
      4 def convert(number):
      5     """Converts a number into a string that contains raindrop sounds
      6     corresponding to certain potential factors."""
      7     sound = ""
      8     digit=True
      9 
     10     if number % 3 == 0:
     11         sound += "Pling"
     12         digit=False
     13     if number % 5 == 0:
     14         sound += "Plang"
     15         digit=False
     16     if number % 7 == 0:
     17         sound += "Plong"
     18         digit=False
     19     if digit: sound = f"{ number }"
     20 
     21     return sound