-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyEditor.py
More file actions
48 lines (47 loc) · 1.65 KB
/
PyEditor.py
File metadata and controls
48 lines (47 loc) · 1.65 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import sys
print("Welcome to Python 2 Text Editor")
condition = True
while condition == True:
print("""What do you want to do:
1. Creating a new file
2. Writing to a saved file
3. Viewing a saved file
4. Exit """)
choice=eval(input("Enter your choice: "))
if choice==4:
sys.exit()
elif choice==3:
mode="r"
file_name=input("Enter your filename: ")
File=open(file_name,mode)
print(File.read())
elif choice==2:
mode="a+"
file_name=input("Enter your filename: ")
File=open(file_name,mode)
print(File.read())
File.close()
File=open(file_name,mode)
while True:
new_text=input()
File.write((new_text)+'\n')
elif choice==1:
mode="w+"
file_name=input("Enter your filename: ")
File=open(file_name,mode)
File.truncate()
print("Start writing your text from here(Press Ctrl+Z and then Press Enter for stop writing): ")
while True:
new_text=input()
File.write((new_text)+'\n')
else:
print("Invalid choice entered")
char=input("Press C/c to continue and Q/q to quit: ")
if char=='C' or char == 'c':
condition=True
elif char=='q' or char=='Q':
condition=False
else:
print("Invalid choice entered")
File.close()
#addong a commit, bruuuh.