txt = input("Please type in your text here ")
txt = txt.expandtabs(3)
print(txt)
I found this built-in method in the python documentation but it doesn't seem to do the job. Which method should I go for instead? The goal here is to render 3 periods (...) for every empty space the user types in.
CodePudding user response:
expandtabs()
is used for setting the tab size and not replacing the spaces. However, you can use str.replace()
to replace any given substring with another.
txt = input("Please type in your text here ")
txt = txt.replace(' ', '...')
print(txt)