Phone

+919997782184

Email

support@roboticswithpython.com

Geeks of Coding

Join us on Telegram

Home Forums Assignment courserra Python for Everybody – Specialization Python Data Structures Assignment 6.5, Python for Data Structure

Viewing 0 reply threads
  • Author
    Posts
    • #807
      Abhishek TyagiAbhishek Tyagi
      Keymaster

      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.

        Answer
      text = "X-DSPAM-Confidence:    0.8475";
      
      spacePos = text.find(" ")
      number = text[spacePos::1]
      #not really necessary but since we are just learning and playing
      strippedNumber = number.lstrip();
      result = float(strippedNumber)
      
      def reprint(printed):
          print(printed) 
      
      reprint(result)
Viewing 0 reply threads
  • You must be logged in to reply to this topic.