-3

I want to know how to use try and except inside a function and what change will it bring to my syntax of code.

I was trying to use this tags inside one function but error was coming and my program was not running successfully.

2
  • 3
    Could we see some code? Preferably a minimum reproducible example. Commented Dec 27, 2022 at 4:58
  • 1
    This seems like something you'd learn from any decent Python tutorial or book, rather than SO. Commented Dec 27, 2022 at 5:00

1 Answer 1

0

Try and except catch errors and you can use them to give responses to those errors.

Here is an example of try and except:

variable_name = "Hello world!"

try:
    print(variable_name + 3)
except ValueError as e:
    print(e)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.