Advertisement
dvdjaco

6.5

Feb 18th, 2012
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. # #!/usr/bin/python
  2. #
  3. # By dvdjaco
  4. # Exercise 6.5
  5. #
  6. # Take the following Python code that stores a string:
  7. # str = 'X-DSPAM-Confidence: 0.8475'
  8. # Use find and string slicing to extract the portion of the string after the colon character and then use the float function to convert the extracted string into a floating point number.
  9.  
  10. string = 'X-DSPAM-Confidence: 0.8475'
  11.  
  12. pos_colon = string.find(':')
  13. str_num = string[pos_colon + 1:]
  14. num = float(str_num)
  15.  
  16. print num
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement