Language…
13 users online: caioskii, Cristian Cardoso, fanfan21, Golden Yoshi, Green Jerry, JezJitzu, Josuke Yoshikage, KoJi, Maw,  Nanako, Shomi, tOaO, yoshi9429 - Guests: 249 - Bots: 287
Users: 64,795 (2,377 active)
Latest user: mathew

Python 3 question

So let's say I have this Python 3 code. theString is a string. code

Trying to run this will give an error of something like, "str object doesn't support item assignment".

What I want to do is replace all instances of r in theString with h, but how do I write to theString?

I'm VERY inexperienced with Python. I would much rather use C++, but a homework assignment requires me to use Python 3.

(O.K., for some reason, SMWCentral glitches out if I post the code directly, so it's in the text document.)

Click the character on the right side of my layout to visit my Discord server and discuss and play and look at and get updates and sneak peeks of the games and other things I'm making.

The authors of these 2 My Little Pony fan games have removed their games from the Internet.
Rise of the Clockwork Stallions has been updated! Download My Little Pony: Rise of the Clockwork Stallions DX: Director's Cut and My Little Pony: Magic Shards now! Spread this link!

Python strings are immutable, you can't change them. You have to create a new one based on the old.

For example theString = theString.replace("r","h").

also the glitches are due to bbcode. Change your loop index variable 'i' to any letter other than 'b' 'i' 'u' 's' and it'll work.
<blm> zsnes users are the flatearthers of emulation