Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3.2
- # -*- coding: utf-8 -*-
- # main.py
- """ Task: Exercise 6.5
- Take the following Python code that stores a string:
- str = 'X-DSPAM-Confidence: 0.8475'
- 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.
- """
- ''' Main '''
- string = 'X-DSPAM-Confidence: 0.8475'
- strPos = string.find(':')
- fpNumber = string[strPos+1:]
- fpNumber = fpNumber.strip()
- fpNumber = float(fpNumber)
- print(str(fpNumber) + " - " + str(type(fpNumber)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement