Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Exception Alias | Handling Structure
Error Handling in Python
course content

Kursinnhold

Error Handling in Python

Error Handling in Python

1. Handling Structure
2. Exception Usage

book
Exception Alias

When you catch an exception (error), you can save information about this exception using the as keyword.

The full alias structure:

python

The alias allows us to display information about caught errors.
Look at the example:

1234567
try: a = "string" + 10 except TypeError as error: print("TypeError:", error) print("The following code should be executed:") print("5 + 10 =", 5 + 10)
copy

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 5

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

course content

Kursinnhold

Error Handling in Python

Error Handling in Python

1. Handling Structure
2. Exception Usage

book
Exception Alias

When you catch an exception (error), you can save information about this exception using the as keyword.

The full alias structure:

python

The alias allows us to display information about caught errors.
Look at the example:

1234567
try: a = "string" + 10 except TypeError as error: print("TypeError:", error) print("The following code should be executed:") print("5 + 10 =", 5 + 10)
copy

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 5
Vi beklager at noe gikk galt. Hva skjedde?
some-alt