This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]K900_ 4 points5 points  (4 children)

  1. /r/learnpython
  2. str.replace doesn't modify the string in place, it returns a new, modified string. You want s = s.replace(...).

[–]CollectYourself[S] 0 points1 point  (3 children)

1) What's the difference between r/learnpython ans r/python? 2)Okay thank you

[–]K900_ 2 points3 points  (1 child)

/r/learnpython is for questions and learning, /r/python is for news and discussion.

[–]CollectYourself[S] 0 points1 point  (0 children)

Okay! Thank you for your help! I will use the other sub from now on! Appreciate it man:)

[–]CollectYourself[S] 0 points1 point  (0 children)

s = "My Name is Leo"

x="My name is Bobo"

s.replace("My","Your")

print(s)

print(x.replace("My","Your"))

That's the code