Don't like ads? PRO users don't see any ads ;-)
Guest

6.2

By: dvdjaco on Feb 18th, 2012  |  syntax: Python  |  size: 0.40 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # #!/usr/bin/python
  2. #
  3. # By dvdjaco
  4. # Exercise 6.2
  5. #
  6. # Given that fruit is a string, what does fruit[:] mean?
  7. #
  8. # R: fruit[:] slices the string stored in the variable fruit starting in the beginning of the string and finishing in the end of the string, thus returning the same string.
  9.  
  10. fruit1 = 'apple'
  11. print fruit1
  12. print len(fruit1)
  13.  
  14. fruit2 = fruit1[:]
  15. print fruit2
  16. print len(fruit2)