string.replace() returns the string with the replaced values. It doesn't modify the original so do something like this:

link['href'] = link['href'].replace("..", "")
Answer from joel goldstick on Stack Overflow
🌐
Python.org
discuss.python.org › python help
Hi! I am a newbie. Why doesn't list.replace() work? Help! - Python Help - Discussions on Python.org
March 19, 2022 - Hey! I was working on a text adventure game and was trying to remove a part of dis3 after the player takes the item in isect3(). Here is my code Help = "NO CAPS l=look n=north s=south e=east w=west u=up d=down ew=eastwest take (item) l (item) use (item) r=restart drop (item) take all" inventory = ['$10 bill'] appearance = "dirty" #1 sect1 = ["l", "n", "s", "l door"] sect2 = ["l", "w", "s", "l shelf"] sect3 = ["l", "n", "s", "e", "w", "l shovel", "l flo...
Discussions

Str.replace not working?
You probably just want this: updated['twitter_handle'] = updated['twitter_handle'].replace('?langen', '') More on reddit.com
🌐 r/learnpython
7
1
January 20, 2021
python - String replacement not working - Stack Overflow
I'm a bit embarrassed to ask: but why won't this successfully work? the .statswith method is fine here, returning True, but i can't get this replace to work... sandwich = "Au Cheval Cheeseburger" More on stackoverflow.com
🌐 stackoverflow.com
Does the character being replaced in .replace() have to be nonempty?
Question In the context of this exercise, does the character being replaced in the .replace() method have to be nonempty? Answer No, the character being replaced in the .replace() method does not have to be a nonempty string, and can be the empty string ''. When providing an empty string as ... More on discuss.codecademy.com
🌐 discuss.codecademy.com
0
9
October 30, 2018
Struggling with replace method
I am trying to write this code to check if any of the ord values of the characters in the argument string are multiples of the number in the argument, and then remove them. For some reason it is only removing the h, even though if I ask it to print the values to be replaced it outputs b, d, ... More on discuss.python.org
🌐 discuss.python.org
4
0
April 8, 2024
🌐
Reddit
reddit.com › r/learnpython › why doesn’t my replace method work?
r/learnpython on Reddit: Why doesn’t my replace method work?
February 22, 2022 -

So I was doing some basic coding challenges and one of them was to replace the first letter with the last letter (pretty simple right?) for some strings. I’ll give only 1 string for this example.

Edit - idk how to indent on Reddit sorry

str = “Chocolate”

Expected output = “ehocolatC”

So I wrote —

front = str[:1] back = str[-1:]

str.replace(back,front) str.replace(front,back)

output = “ChocolatC”

(So now if you are noobie like me your first thought was “oh yeah it’s because once you call the first replace function because back turns into a C the second replace function will replace a C with a C”)

So then I added a temp

front = str[:1] back = str[-1:]

tempBack = str[-1:] str.replace(back,front) str.replace(front,tempBack)

output = “ChocolatC”

Idk why please help a noob out Btw I even tested it by printing tempBack out right before replace(front,tempBack) and the output was an e!!! Tf?

🌐
Real Python
realpython.com › replace-string-python
How to Replace a String in Python – Real Python
October 22, 2025 - $ python transcript_multiple_replace.py Agent 10:02:23 : What can I help you with? Client 10:03:15 : I CAN'T CONNECT TO MY 😤 ACCOUNT Agent 10:03:30 : Are you sure it's not your caps lock? Client 10:04:03 : 😤! You're right! That’s a pretty clean transcript. Maybe that’s all you need. But if your inner automator isn’t happy, maybe it’s because there are still some things that may be bugging you: Replacing the swear words won’t work if there’s another variation using -ing or a different capitalization, like BLAst.
🌐
Server Academy
serveracademy.com › blog › python-replace-function
Python Replace() Function Blog | Server Academy
November 14, 2024 - The method in Python is a powerful tool for working with strings, allowing you to replace parts of a string with new values. Whether you’re changing characters…
🌐
Mimo
mimo.org › glossary › python › string-replace-method
Master Python's String Replace Method for Text Manipulation
Start your coding journey with Python. Learn basics, data types, control flow, and more ... The replace() method returns a copy of the string after replacing the substrings without changing the original string.
Find elsewhere
🌐
JanBask Training
janbasktraining.com › community › python-python › python-string-replace-not-working1
python string replace not working | JanBask Training Community
April 5, 2021 - name = abc000 name.replace(“000”,””) It showed proper output in the python interpreter. Then I tried it in Pycharm by adding the following line print(name) but still not working.
🌐
JanBask Training
janbasktraining.com › community › python-python › how-can-i-solve-the-error-of-python-replace-not-working
How can I solve the error of “Python replace not working?” | JanBask Training Community
December 18, 2023 - # Example where the result of ... str. replace() method:- Ensure that you are applying the “replace “ function effectively on the strings and also assigning its result back to the variables....
🌐
W3Schools
w3schools.com › python › ref_string_replace.asp
Python String replace() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... The replace() method replaces a specified phrase with another specified phrase. Note: All occurrences of the specified phrase will be replaced, if nothing else is specified.
🌐
Python Forum
python-forum.io › thread-14449.html
"replace() method" fails to change string
Hi all, New to Python and this forum so I guess i am missing something simple. Why does this string method work in the Python shell but not when used in my PyCharm program? Python version seems to make no difference. import os s = 'ghghkc' s.replac...
🌐
GeeksforGeeks
geeksforgeeks.org › python-string-replace
Python String replace() Method - GeeksforGeeks
October 28, 2024 - Explanation: Here, "Hello" is replaced by "Hi" throughout the string, resulting in "Hi World! Hi Python!". Note: Since replace() creates a new string, the original string remains unchanged.
🌐
Edureka Community
edureka.co › home › community › categories › python › python string replace not working
Python string replace not working | Edureka Community
April 4, 2019 - Hi. I am trying to replace some characters in python string but it is not working. I am using ... line print(name) but it is not working.
🌐
Hyperskill
hyperskill.org › university › python › replace-method-in-python
Python replace() Method
July 17, 2024 - Python is the best!" new_sentence = sentence.replace("Python", "Java") print(new_sentence) # Output: I love Java. Java is the best! An original string refers to the initial sequence of characters before any modifications are made using the replace method. The replace method creates a new string with specified replacements, while keeping the original string unchanged.
🌐
Shiksha
shiksha.com › home › it & software › it & software articles › programming articles › how to use python replace function
How to use Python Replace function - Shiksha Online
October 26, 2023 - If you are following the article very closely, you will notice that we are replacing the perfect matching substring, i.e., if we have to replace ‘P’ in Python with ‘S’, then we have to use replace(‘P’, ‘S’); otherwise, it will return the old string.
🌐
iO Flood
ioflood.com › blog › python-string-replace
Python String Replace Methods | Using replace() and More
August 19, 2024 - In Python, certain characters have special meanings, such as '\n' for a newline or '\t' for a tab. If you try to replace these using the replace() method, you might not get the results you expect.
🌐
Codecademy Forums
discuss.codecademy.com › frequently asked questions › python faq
Does the character being replaced in .replace() have to be nonempty? - Python FAQ - Codecademy Forums
October 30, 2018 - Question In the context of this exercise, does the character being replaced in the .replace() method have to be nonempty? Answer No, the character being replaced in the .replace() method does not have to be a nonempty string, and can be the empty string ''. When providing an empty string as the argument for the character to be replaced, this will essentially replace every part between characters in the string.
🌐
Python.org
discuss.python.org › python help
Struggling with replace method - Python Help - Discussions on Python.org
April 8, 2024 - I am trying to write this code to check if any of the ord values of the characters in the argument string are multiples of the number in the argument, and then remove them. For some reason it is only removing the h, even though if I ask it to print the values to be replaced it outputs b, d, and f as well.