15: Error handling in python

Extend it:

Make your code cope when things go wrong
Error handling: Make your code cope when things go wrong

For this challenge you will need to use exception handling to catch common run time errors

Challenges:

 
  1. Use try and except around some code which tries to convert user input to an integer

    Hint: Surround a section of code which uses the int function to convert a string to an integer with try…except…

  2. Use try and except around some code which tries to convert user input to an real/float

    Hint: Surround a section of code which uses the float function to convert a string to an float / real with try…except…

  3. Use try and except around some code which tries to open a file

    Hint: Surround a section of code which uses the open function with try…except…

Leave a Reply

Your email address will not be published. Required fields are marked *