This is a Kata challenge. The function should return a string with spaces between each character. So "Hi there" should equal the the string with spaces between each letter, two spaces between the words. My code actually works in my Python environment, but it is not accepted on Kata.
def spacing(string):
return " ".join(a for a in string).split(string)
A string when iterated over is considered a sequence of characters, so you can simply pass the string to the join method directly:
def spacing(string):
return ' '.join(string)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With