@@ -12015,13 +12015,22 @@ <h2 id="str.replace()"><code>str.replace()</code><a class="anchor-link" href="#s
12015
12015
</ div >
12016
12016
</ div >
12017
12017
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 >
12018
12027
</ div >
12019
12028
< div class ="cell border-box-sizing code_cell rendered ">
12020
12029
< div class ="input ">
12021
12030
< div class ="prompt input_prompt "> In [7]:</ div >
12022
12031
< div class ="inner_cell ">
12023
12032
< 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 cl
10000
ass ="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 >
12025
12034
< span class ="nb "> print</ span > < span class ="p "> (</ span > < span class ="n "> my_string</ span > < span class ="p "> )</ span >
12026
12035
</ pre > </ div >
12027
12036
@@ -12039,14 +12048,23 @@ <h2 id="str.replace()"><code>str.replace()</code><a class="anchor-link" href="#s
12039
12048
12040
12049
12041
12050
< 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 !
12043
12052
</ pre >
12044
12053
</ div >
12045
12054
</ div >
12046
12055
12047
12056
</ div >
12048
12057
</ div >
12049
12058
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 >
12050
12068
</ div >
12051
12069
< div class ="cell border-box-sizing code_cell rendered ">
12052
12070
< div class ="input ">
@@ -12071,7 +12089,7 @@ <h2 id="str.replace()"><code>str.replace()</code><a class="anchor-link" href="#s
12071
12089
12072
12090
12073
12091
< 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 !
12075
12093
</ pre >
12076
12094
</ div >
12077
12095
</ div >
0 commit comments