@@ -12015,13 +12015,22 @@ <h2 id="str.replace()"><code>str.replace()</code><a class="anchor-link" href="#s
1201512015</ div >
1201612016</ div >
1201712017
12018+ </ div >
12019+ < div class ="cell border-box-sizing text_cell rendered "> < div class ="prompt input_prompt ">
12020+ </ div >
12021+ < div class ="inner_cell ">
12022+ < div class ="text_cell_render border-box-sizing rendered_html ">
12023+ < p > This will not modify < code > my_string</ code > because replace is not done in-place.</ p >
12024+
12025+ </ div >
12026+ </ div >
1201812027</ div >
1201912028< div class ="cell border-box-sizing code_cell rendered ">
1202012029< div class ="input ">
1202112030< div class ="prompt input_prompt "> In [7]:</ div >
1202212031< div class ="inner_cell ">
1202312032 < div class ="input_area ">
12024- < div class =" highlight hl-ipython3 "> < pre > < span > </ span > < span class ="n "> my_string</ span > < span class =" o " > = </ span > < span class =" n " > my_string </ span > < span class ="o "> .</ span > < span class ="n "> replace</ span > < span class ="p "> (</ span > < span class ="s1 "> 'a'</ span > < span class ="p "> ,</ span > < span class ="s1 "> '?'</ span > < span class ="p "> )</ span >
12033+ < div class =" highlight hl-ipython3 "> < pre > < span > </ span > < span class ="n "> my_string</ span > < span class ="o "> .</ span > < span class ="n "> replace</ span > < span class ="p "> (</ span > < span class ="s1 "> 'a'</ span > < span class ="p "> ,</ span > < span class ="s1 "> '?'</ span > < span class ="p "> )</ span >
1202512034< span class ="nb "> print</ span > < span class ="p "> (</ span > < span class ="n "> my_string</ span > < span class ="p "> )</ span >
1202612035</ pre > </ div >
1202712036
@@ -12039,14 +12048,23 @@ <h2 id="str.replace()"><code>str.replace()</code><a class="anchor-link" href="#s
1203912048
1204012049
1204112050< div class ="output_subarea output_stream output_stdout output_text ">
12042- < pre > Python is my f?vorite progr?mming l?ngu?ge !
12051+ < pre > Python is my favorite programming language !
1204312052</ pre >
1204412053</ div >
1204512054</ div >
1204612055
1204712056</ div >
1204812057</ div >
1204912058
12059+ </ div >
12060+ < div class ="cell border-box-sizing text_cell rendered "> < div class ="prompt input_prompt ">
12061+ </ div >
12062+ < div class ="inner_cell ">
12063+ < div class ="text_cell_render border-box-sizing rendered_html ">
12064+ < p > You have to store the return value of < code > replace</ code > instead.</ p >
12065+
12066+ </ div >
12067+ </ div >
1205012068</ div >
1205112069< div class ="cell border-box-sizing code_cell rendered ">
1205212070< div class ="input ">
@@ -12071,7 +12089,7 @@ <h2 id="str.replace()"><code>str.replace()</code><a class="anchor-link" href="#s
1207112089
1207212090
1207312091< div class ="output_subarea output_stream output_stdout output_text ">
12074- < pre > Python will be my f?vorite progr?mming l?ngu?ge !
12092+ < pre > Python will be my favorite programming language !
1207512093</ pre >
1207612094</ div >
1207712095</ div >
0 commit comments