DEV Community

Discussion on: python challenge_6

Collapse
 
shapeshapa profile image
shapa • Edited

I would prefer to use an extended class of string, it wil be much more reusable.

class Dots(str):
    def __init__(self, value: str):
        self.value = value

    def add_dots(self):
        return self.__class__(".".join(self.value))

    def remove_dots(self):
        return self.__class__(".".replace(".", ""))

msg = Dots("Hello")
print(msg.add_dots())
print(msg.add_dots().lower())
Enter fullscreen mode Exit fullscreen mode
Collapse
 
mahmoudessam profile image
Mahmoud EL-kariouny • Edited

It is very good, But in my case I did have to follow the instructions
this is link of all challenges I work on it : pythonprinciples.com/challenges/