#5, First Floor, 4th Street , Dr. Subbarayan Nagar, Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

Shopping list program using python control flow statement?
Description

To create a shopping list program using python control flow statements.

Process

  Print help.

   Print list.

   Add the items in to list.

   Print the items in the list.

   Quit the program.

Sapmle Code

#CREATE EMPTY LIST

shopping_list = []

def print_help():

#PRINT HELP

print(“What do you want to add today?”)

print(“””Type “DONE” to quit

Type “HELP” to see help

Type “SHOW”

to see current shopping list”””)

def print_items():

#PRINT THE LIST

print(“You’ve got in your shopping list: “)

for item in shopping_list:

print(item)

def add_item(new_item):

shopping_list.append(new_item)

print(“Added {}, you got {}

items in your list”. format

(new_item, len(shopping_list)))

print_help()

while True:

#NEED TO PUT ITEMS INTO THE LIST

new_item = input(“> “)

#QUIT THE PROGRAM

if new_item.upper() == “DONE”:

break

elif new_item.upper() == “HELP”:

print_help()

continue

elif new_item.upper() == “SHOW”:

print_items()

continue

add_item(new_item)

print_items()

Screenshots