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

bookChallenge: Secure Exception Handling

Opgave

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 alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 6
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

Awesome!

Completion rate improved to 5.56

bookChallenge: Secure Exception Handling

Stryg for at vise menuen

Opgave

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 desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 6
single

single

some-alt