 Exception Alias
Exception Alias
When you catch an exception (error), you can save information about this exception using the as keyword.
The full alias structure:
except {error_type} as {variable_name}:
    # code block
The alias allows us to display information about caught errors.
Look at the example:
1234567try: a = "string" + 10 except TypeError as error: print("TypeError:", error) print("The following code should be executed:") print("5 + 10 =", 5 + 10)
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 5
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Suggested prompts:
Still meg spørsmål om dette emnet
Oppsummer dette kapittelet
Vis eksempler fra virkeligheten
Awesome!
Completion rate improved to 11.11 Exception Alias
Exception Alias
Sveip for å vise menyen
When you catch an exception (error), you can save information about this exception using the as keyword.
The full alias structure:
except {error_type} as {variable_name}:
    # code block
The alias allows us to display information about caught errors.
Look at the example:
1234567try: a = "string" + 10 except TypeError as error: print("TypeError:", error) print("The following code should be executed:") print("5 + 10 =", 5 + 10)
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 5