Last active
May 23, 2024 18:22
-
-
Save Mohamed2del/66f0b9a733e021f7537787be40febe43 to your computer and use it in GitHub Desktop.
Write code using find() and string slicing (see section 6.10) to extract the number at the end of the line below. Convert the extracted value to a floating point number and print it out.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = "X-DSPAM-Confidence: 0.8475"; | |
startPos = text.find(':') | |
piece = text[startPos+1:] | |
end = float(piece) | |
print(end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
text = "X-DSPAM-Confidence: 0.8475"
a = text.find('0')
f = float(text[a:])
print(f)