Skip to content

Instantly share code, notes, and snippets.

@zcakzwa
Created July 5, 2016 03:53
Show Gist options
  • Save zcakzwa/5882d461ed97829e068531282b32d7ec to your computer and use it in GitHub Desktop.
Save zcakzwa/5882d461ed97829e068531282b32d7ec to your computer and use it in GitHub Desktop.
6.5 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.
text = "X-DSPAM-Confidence: 0.8475";
t = text.find("0")
h = text[t:t+6]
h = float(h)
print h
@NaomiPham200296
Copy link

text = "X-DSPAM-Confidence: 0.8475"
a=text.find('0')
b=text.find('5')
c=text[a:b+1]
print(float(c))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment