File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -788,7 +788,7 @@ compute x + 1, you have to create another integer and give it a name.
788
788
789
789
my_list = [1 , 2 , 3 ]
790
790
my_list[0 ] = 4
791
- print my_list # [4, 2, 3] <- The same list has changed
791
+ print ( my_list) # [4, 2, 3] <- The same list has changed
792
792
793
793
x = 6
794
794
x = x + 1 # The new x is another object
@@ -822,7 +822,7 @@ most idiomatic way to do this.
822
822
nums = " "
823
823
for n in range (20 ):
824
824
nums += str (n) # slow and inefficient
825
- print nums
825
+ print ( nums)
826
826
827
827
**Better **
828
828
@@ -832,15 +832,15 @@ most idiomatic way to do this.
832
832
nums = []
833
833
for n in range (20 ):
834
834
nums.append(str (n))
835
- print " " .join(nums) # much more efficient
835
+ print ( " " .join(nums) ) # much more efficient
836
836
837
837
**Best **
838
838
839
839
.. code-block :: python
840
840
841
841
# create a concatenated string from 0 to 19 (e.g. "012..1819")
842
842
nums = [str (n) for n in range (20 )]
843
- print " " .join(nums)
843
+ print ( " " .join(nums) )
844
844
845
845
One final thing to mention about strings is that using ``join() `` is not always
846
846
best. In the instances where you are creating a new string from a pre-determined
You can’t perform that action at this time.
0 commit comments