Question: print ( Price as float:, price ) except: print ( That ' s not a price! ) Using a string method from unit

print("Price as float:", price) except: print("That's not a price!")
Using a string method from unit 5, complete the program so that it can detect if a price string can be converted to a floating point number and convert it. The completed program should consider the following inputs correct:
12 will print Price as float: 12.0
$12 will print Price as float: 12.0
$14.95 will print Price as float: 14.95
The completed program should flag the following inputs as incorrect.
spam will print That's not a price!
9.99% will print That's not a price!
price =1$ will print That's not a price!
Enter one or more statement that can go into the try block to complete it:
 print("Price as float:", price) except: print("That's not a price!") Using a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!