Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d5af7b

Browse files
Merge pull request avinashkranjan#907 from Avishake007/todolist
Added Todolist Cli-Version
2 parents 10478aa + 0cd0d8d commit 5d5af7b

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

‎TODO (CLI-VER)/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
<h1 align="center">Todo List CLI-VER</h1>
3+
List down your items in a Todolist so that you don't forget
4+
5+
---------------------------------------------------------------------
6+
7+
8+
9+
## How it works
10+
- If you don't have todolist.txt file in the current folder it will create one for you
11+
- You can add items to the list
12+
- You can delete items from the list
13+
- You can update items in the list
14+
- You can display Items as well
15+
16+
#### By [Avishake Maji](https://github.com/Avishake007)

‎TODO (CLI-VER)/todolist.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#Check for the existence of file
2+
no_of_items=0
3+
try:
4+
f=open("./TODO (CLI-VER)/todolist.txt")
5+
p=0
6+
for i in f.readlines():#Counting the number of items if the file exists already
7+
p+=1
8+
no_of_items=p-2
9+
except:
10+
f=open("./TODO (CLI-VER)/todolist.txt",'w')
11+
f.write("_________TODO LIST__________\n")
12+
f.write(" TIME WORK")
13+
finally:
14+
f.close()
15+
#Todo list
16+
print("Press 1: Add Item \nPress 2: Delete Item \nPress 3: Update item \nPress 4: Display Items\nPress 5: Exit")
17+
n=int(input())
18+
while n==1 or n==2 or n==3 or n==4:
19+
if n==1:
20+
todo=[]
21+
print("Enter the time in HH:MM format(24 hours format)")
22+
time=input()
23+
print("Enter your Work")
24+
work=input()
25+
no_of_items+=1
26+
with open('./TODO (CLI-VER)/todolist.txt','a') as f:
27+
f.write("\n"+str(no_of_items)+" "+time+" "+work)
28+
elif n==2:
29+
if(no_of_items<=0):
30+
print("There is no item in the list kindly add some items")
31+
else:
32+
print("____________________________________________________________")
33+
print("Your Current List: ")
34+
todo=[]
35+
with open('./TODO (CLI-VER)/todolist.txt') as f:
36+
for i in f.readlines():
37+
print(i)
38+
todo.append(i)
39+
print("____________________________________________________________")
40+
print("Enter the position of the item you want to delete : ")
41+
pos=int(input())
42+
if(pos<=0):
43+
print("Please enter a valid position")
44+
elif (pos>(no_of_items)):
45+
print("Please enter the position <= {}".format(no_of_items))
46+
else:
47+
48+
todo.pop(pos+1)
49+
no_of_items-=1
50+
if(no_of_items<=0):
51+
print("Congratulations your todo list is empty!")
52+
53+
with open('./TODO (CLI-VER)/todolist.txt','w') as f:
54+
for i in range(len(todo)):
55+
if i>=(pos+1):
56+
f.write(str(pos)+todo[i][1:])
57+
pos+=1
58+
else:
59+
f.write(todo[i])
60+
61+
elif n==3:
62+
print("____________________________________________________________")
63+
print("Your Current List: ")
64+
todo=[]
65+
with open('./TODO (CLI-VER)/todolist.txt') as f:
66+
for i in f.readlines():
67+
print(i)
68+
todo.append(i)
69+
print("____________________________________________________________")
70+
print("Enter the position of the items you want to update : ")
71+
pos=int(input())
72+
if(pos<=0):
73+
print("Please enter a valid position")
74+
elif (pos>(no_of_items)):
75+
print("Please enter the position <= {}".format(no_of_items))
76+
else:
77+
print("What you want to update : ")
78+
print("Press 1: Time\nPress 2: Work")
79+
choice=int(input())
80+
if choice==1:
81+
print("Enter your updated time :")
82+
time=input()
83+
p=todo[pos+1].index(":")
84+
y=0
85+
with open('./TODO (CLI-VER)/todolist.txt','w') as f:
86+
for i in range(len(todo)):
87+
if i==pos+1:
88+
f.write(str(pos)+" "+time+""+''.join(todo[pos+1][p+3:]))
89+
else:
90+
f.write(todo[i])
91+
elif choice==2:
92+
print("Enter your updated work :")
93+
work=input()
94+
p=todo[pos+1].index(":")
95+
y=0
96+
with open('./TODO (CLI-VER)/todolist.txt','w') as f:
97+
for i in range(len(todo)):
98+
if i==pos+1:
99+
f.write(str(pos)+" "+''.join(todo[pos+1][p-2:p+3])+" "+work)
100+
else:
101+
f.write(todo[i])
102+
elif n==4:
103+
print("Your Current List: ")
104+
todo=[]
105+
print("____________________________________________________________")
106+
with open('./TODO (CLI-VER)/todolist.txt') as f:
107+
for i in f.readlines():
108+
print(i)
109+
todo.append(i)
110+
print("____________________________________________________________")
111+
print("Press 1: Add Item \nPress 2: Delete the Item\nPress 3: Update item\nPress 4:Display Items\nPress 5:Exit")
112+
n=int(input())
113+
print("Thank you for using our application")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /