Skip to content

Commit d3e1624

Browse files
Add files via upload
1 parent ed05d3e commit d3e1624

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

Grocery List Creator.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
'''
2+
This is a full functional grocery list Python program example to add to my Python book.
3+
Feel free to copy this Python program example if you like. See what you can do with it.
4+
As time rolls on, I will make this an actual, working program, which the user can place
5+
the price of a grocery list item, while it keeps track of what you will be spending at the
6+
store. The user will also be able to clear the list items or clear just one single list item,
7+
while the price part of the program will work as addition and subtraction of list pricing,
8+
via items added or removed from the shopping list. You are all welcome to copy this
9+
program and make it do and be anything you like. Maybe try and create the list, such as
10+
what I want to make it do down the road. Please enjoy.
11+
'''
12+
import os
13+
14+
title='title Grocery List Creator'
15+
clear_screen='cls'
16+
single_line_break='\n'
17+
double_line_break='\n\n'
18+
indent=' '*2
19+
dot_space='.'*3
20+
create_list='vgl'
21+
button1='y'
22+
button2='n'
23+
enter=''
24+
25+
os.system(title)
26+
27+
sentence=[
28+
f'{single_line_break}{indent}Grocery List Creator', # index 0
29+
30+
f'''{double_line_break}{indent}Press "Enter" after each grocery list item typed.
31+
{indent}Type "vgl", then press "Enter" to view your grocery list output.''', # index 1
32+
33+
f'{double_line_break}{indent}Please type your grocery list items: ', # index 2
34+
35+
f'{single_line_break}{indent}You have', # indext 3
36+
37+
'items in your grocery list.', # index 4
38+
39+
f'{double_line_break}{indent}Here is your grocery list output:', # index 5
40+
41+
f'''{single_line_break}{indent}Do you wish to add more items to your grocery list?
42+
{indent}Press "y" or "n" to confirm: ''' # index 6
43+
]
44+
45+
user_data=set()
46+
user_data.add(enter)
47+
48+
def items_list():
49+
while True:
50+
os.system(clear_screen)
51+
grocery_list=input(sentence[0]\
52+
+sentence[1]+sentence[2]).strip()
53+
user_data.add(grocery_list)
54+
if grocery_list==create_list:
55+
user_data.remove(create_list)
56+
convert=list(user_data)
57+
convert.remove(enter)
58+
convert.sort()
59+
break
60+
61+
while True:
62+
os.system(clear_screen)
63+
print(sentence[0]+sentence[5])
64+
65+
x=1
66+
for i in convert:
67+
print(f'{single_line_break}{indent}{x}) {dot_space}',i.title())
68+
x+=1
69+
70+
print(sentence[3],len(convert),sentence[4])
71+
grocery_list=input(sentence[6]).lower().strip()
72+
73+
if grocery_list==button1:
74+
items_list()
75+
break
76+
elif grocery_list==button2:
77+
break
78+
79+
items_list()
80+
input('end')

0 commit comments

Comments
 (0)