Challenge: Debugging a Broken Program
Swipe to start coding
You are given a program that attempts to read the contents of a file and print them to the console. However, if the file does not exist, the program throws an exception and crashes. Your task is to fix the program so that it handles the missing file gracefully and no longer crashes when the file is absent.
- Return
"File does not exist."if the file at the given path is missing. - Otherwise, return the contents of the file.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Can you explain this in simpler terms?
What are the main takeaways from this?
Can you give me a real-world example?
Geweldig!
Completion tarief verbeterd naar 4.17
Challenge: Debugging a Broken Program
Veeg om het menu te tonen
Swipe to start coding
You are given a program that attempts to read the contents of a file and print them to the console. However, if the file does not exist, the program throws an exception and crashes. Your task is to fix the program so that it handles the missing file gracefully and no longer crashes when the file is absent.
- Return
"File does not exist."if the file at the given path is missing. - Otherwise, return the contents of the file.
Oplossing
Bedankt voor je feedback!
single