On Tue, Aug 19, 2008 at 11:30 AM, Rolandb <[EMAIL PROTECTED]> wrote:
>
> Hi. Look at this:
> vv='abc'
> print vv[0]
> vv.replace('b','n')
> print vv
> vv.replace('b','n')
> The answers are different!?...
Strings are immutable, which means vv.replace('b','n')
does *not* change vv, but returns a new string.
And the two outputs of vv.replace are the same, by the way:
sage: vv='abc'
sage: print vv[0]
a
sage: vv.replace('b','n')
'anc'
sage: print vv
abc
sage: vv.replace('b','n')
'anc'
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---