Lets say I have a word, and I only want to display the first three letters of the word. But the remaining last letters need to show a dash or an asterisk, etc.
For example, if we have the word javascript, then the output should display jav-------, pebbles should display as peb----, or instead of python, the output should display pyt---, etc.
Would str.replace(old, new) or str.replace(old, new, count) work in this case? If yes, then how?
Here is an example I did:
>>> p = "kotlin"
>>> p = p.replace(p[3:], "-")
>>> p
'kot-'
>>>
The desired output would display kot---, however, although it does show the first 3 letters in the word, kot- only shows one dash in the end.
What could be another way to approach this?