Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with replace
#2
It does work.
>>> "green eggs and spam".replace("e", "")
'grn ggs and spam'
But it DOES NOT work in-place. You have to actually assign it's result to something. So...
test = words
test = test.replace("show", "")
test = test.replace("images", "")
print(test)
Reply


Messages In This Thread
Problem with replace - by hello_its_me - Dec-29-2017, 10:05 PM
RE: Problem with replace - by nilamo - Dec-29-2017, 10:14 PM
RE: Problem with replace - by newuserzing - Dec-29-2017, 10:18 PM
RE: Problem with replace - by Mekire - Dec-29-2017, 10:23 PM
RE: Problem with replace - by hello_its_me - Dec-29-2017, 10:33 PM
RE: Problem with replace - by nilamo - Dec-29-2017, 10:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner problem, replace function with for loop Motley_Cow 9 4,741 Sep-13-2019, 06:24 AM
Last Post: Motley_Cow
  problem in replace string into file Saeid_Bibak 1 2,117 Jan-20-2019, 09:46 PM
Last Post: Gribouillis
  Search & Replace - Newlines Added After Replace dj99 3 3,454 Jul-22-2018, 01:42 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020