avatar Bite 169. Simple length converter

Your task is to complete the convert() function. It's purpose is to convert centimeters to inches and vice versa. As simple as that sounds, there are some caveats:


  • The function will take value and fmt parameters:
    • value: must be an int or a float otherwise raise a TypeError
    • fmt: string containing either "cm" or "in" anything else raises a ValueError.
  • returns a float rounded to 4 decimal places.

Assume that if the value is being converted into centimeters that the value is in inches and centimeters if it's being converted to inches.

That's it!

Login and get coding
go back Beginner level
Bitecoin 2X

324 out of 329 users completed this Bite.
Will you be the 325th person to crack this Bite?
Resolution time: ~31 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 2.62 on a 1-10 difficulty scale.
» You can do it! 😌

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help