-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinedx.py
More file actions
29 lines (22 loc) · 951 Bytes
/
inedx.py
File metadata and controls
29 lines (22 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def main():
# Ask the user for input file name
input_file = input("Enter the name of the file to read: ")
try:
# Try opening and reading the file
with open(input_file, "r") as f:
content = f.read()
# Modify the content (example: make it uppercase)
modified_content = content.upper()
# Create an output file
output_file = "modified_" + input_file
with open(output_file, "w") as f:
f.write(modified_content)
print(f"✅ Successfully created '{output_file}' with modified content!")
except FileNotFoundError:
print(" Error: The file was not found. Please check the filename and try again.")
except PermissionError:
print(" Error: You don't have permission to read this file.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
if __name__ == "__main__":
main()