Employers
Jobseekers
Recruiting Partners
Login
Join Hyring
Join Hyring
Lesson
Introduction
Get Started
Syntax
Comments
Variables
Variable Names
Multiple Values
Global Variables
Data Types
Numbers
Casting
Strings
Slicing
String Methods
Format Strings
Booleans
Operators
Arithmetic
Comparison
Logical
Lists
Access Items
Change Items
Add Items
Remove Items
Loop Lists
Comprehension
List Methods
Tuples
Access Tuples
Tuple Methods
Sets
Set Methods
Dictionaries
Access Items
Change Items
Loop Dictionaries
Dictionary Methods
If...Else
Nested If
While Loops
For Loops
Functions
Arguments
args & kwargs
Lambda
Scope
Arrays
Iterators
Classes/Objects
__init__
self
Inheritance
Polymorphism
Modules
Dates
Math
JSON
RegEx
Try...Except
File Handling
Read Files
Write Files
Delete Files
Back to lesson
Python File Handling
Removing a single file
Deleting only if the file exists
Deleting with error handling
Run
Language:
Python
Change Theme
Change orientation
import os os.remove("report.txt") print("File deleted")
import os os.remove("report.txt") print("File deleted")
Output
Click Run to execute this code.