Help Removing Prefixes

I can’t get my output to remove the ‘https://’ prefix. I’m using the latest version of Python on Mac in Sublime Text. Any ideas?

nostarch_url = ''


I am using PyCharm and it works fine.


nostarch_url = ''
result = nostarch_url.removeprefix('https://')
1 Like

Just downloaded it. Consider me a convert. Thank you!

1 Like

It has nothing to do with your IDE, your computer, your operating system or your version of Python. (removeprefix is a relatively recent addition, but in older versions you would get an AttributeError instead.)

It has to do with the fact that no method that you call on a string, changes the string.

When you use these methods, you get a new string object which you have to use instead.

It’s the same with .removeprefix as with .replace or anything else - because the str type is immutable.

1 Like

Wish the textbook mentioned this. Thanks for clarifying! :pray: