@@ -788,7 +788,7 @@ compute x + 1, you have to create another integer and give it a name.
788788
789789 my_list = [1 , 2 , 3 ]
790790 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
792792
793793 x = 6
794794 x = x + 1 # The new x is another object
@@ -822,7 +822,7 @@ most idiomatic way to do this.
822822 nums = " "
823823 for n in range (20 ):
824824 nums += str (n) # slow and inefficient
825- print nums
825+ print ( nums)
826826
827827**Better **
828828
@@ -832,15 +832,15 @@ most idiomatic way to do this.
832832 nums = []
833833 for n in range (20 ):
834834 nums.append(str (n))
835- print " " .join(nums) # much more efficient
835+ print ( " " .join(nums) ) # much more efficient
836836
837837**Best **
838838
839839.. code-block :: python
840840
841841 # create a concatenated string from 0 to 19 (e.g. "012..1819")
842842 nums = [str (n) for n in range (20 )]
843- print " " .join(nums)
843+ print ( " " .join(nums) )
844844
845845One final thing to mention about strings is that using ``join() `` is not always
846846best. In the instances where you are creating a new string from a pre-determined
0 commit comments