Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Secure Exception Handling | Understanding Python Vulnerabilities
Python Security Best Practices

bookChallenge: Secure Exception Handling

Uppgift

Swipe to start coding

Write a function that securely handles exceptions when dividing two numbers. The function must only catch specific exceptions and must not reveal any internal error details in its return value.

  • If division is successful, return the result.
  • If a ZeroDivisionError or TypeError occurs, return the string "An error occurred. Please check your input.".
  • Do not return or expose any exception messages or stack traces.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 6
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Suggested prompts:

Can you explain this in more detail?

What are the main benefits of this approach?

Are there any common mistakes to avoid?

close

Awesome!

Completion rate improved to 5.56

bookChallenge: Secure Exception Handling

Svep för att visa menyn

Uppgift

Swipe to start coding

Write a function that securely handles exceptions when dividing two numbers. The function must only catch specific exceptions and must not reveal any internal error details in its return value.

  • If division is successful, return the result.
  • If a ZeroDivisionError or TypeError occurs, return the string "An error occurred. Please check your input.".
  • Do not return or expose any exception messages or stack traces.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 6
single

single

some-alt