Can you edit a character in a string ?How do you change a string in python?

Posted on

Can you edit a character in a string ?How do you change a string in python?

If p=”nice”

how do I make “nice” into “Nice” ?

The answer is that strings are immutable, meaning they cant be changed.

so you would need to assign p to a a new string

p=”Nice”

cannot do p[0]=’N’

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s