My mini program takes a string from user input and adds dots between each letter and then removes these dots.
The function add_dots takes the string and adds dots. I have a separate function called remove_dots that then removes them.
Here is the code below:
def add_dots(str):
str = ".".join(str)
print(str)
def remove_dots(str):
str.replace(".", "")
print(str)
word = input("Enter a word: ")
When I call the two functions individually with
add_dots(word)
remove_dots(word)
I get the expected console output of
Enter a word: hello
h.e.l.l.o
hello
However, when I try to call
remove_dots(add_dots(word))
I get an error AttributeError: 'NoneType' object has no attribute 'replace'
I understand that this means the str variable has the value of None but I'm not sure why? Can anyone advise. Thanks
add_dotsdoesn'treturnanything, or more precisely,returningNone.returnanything, it only prints.