Question

A specific question I have on this project is how do I make the stars all...

A specific question I have on this project is how do I make the stars all align into making a box. Whenever I post this question the stars on the right edge go in towards the item of the shopping list. I need the starts to create a a box around the shopping items.

Instructions:

Using Python write a program that allows a user to create and use a shopping list. Your
program will display a menu of options to the user. The user is free
to select any option from the menu in any order.


Sample Output:
Welcome to the shopping list program.

Menu
n - New shopping list item
d - Display shopping list
e - Edit an item in the list
c - Check or remove item from list
? - Display this menu
q - Quit program
> n
Enter shopping item: Bread
> n
Enter shopping item: Milk
> n
Enter shopping item: Eggs
> d
********* Shopping list *********
* 1 Bread *
* 2 Milk *
* 3 Eggs *
*********************************
> e
Which item do you want to change?: 2
Enter your change: Whole Milk
> d
********* Shopping list *********
* 1 Bread *
* 2 Whole Milk *
* 3 Eggs *
*********************************
> e
Which item do you want to change?: 10
Error: There is no item at that position
> e
Which item do you want to change?: 0
Error: There is no item at that position
> ?
Menu
n - New shopping list item
d - Display shopping list
e - Edit an item in the list
c - Check or remove item from list
? - Display this menu
q - Quit program
> c
Which item do you want to check?: 10
Error: There is no item at that position
> c
Which item do you want to check?: 1
Item 1 was checked and removed
> d
********* Shopping list *********
* 1 Whole Milk *
* 2 Eggs *
*********************************
> n
Enter shopping item: Ice Cream
> d
********* Shopping list *********
* 1 Whole Milk *
* 2 Eggs *
* 3 Ice Cream *
*********************************
> q
Good bye

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

def printlist(): #displaying function
    print ("Welcome to the shopping list program.")
    print("Menu")
    print("n - New shopping list item")
    print("d - Display shopping list")
    print("e - Edit an item in the list")
    print("c - Check or remove item from list")
    print("? - Display this menu")
    print("q - Quit program")
printlist()
listofitems=[] #list for storing items
while (True): #loop until user enters character q
    menu=input() #take character input from user
    if menu=='n': #if entered character is n
        print("Enter shopping item:",end='')
        listofitems.append(input()) #append item to list
    elif menu=='d': #if entered character is d
        print("********* Shopping list *********")
        for i in range(len(listofitems)): #printing items in the list
            print("* ",end='') #printing * and space
            print(i+1,end=' ') #to print in same line we use end=''
            print(listofitems[i],end='')
            print(" *")
        print("*********************************")
    elif menu=='e': #if entered character is e
        print("Which item do you want to change?: ",end='')
        change=int(input()) #taking changed value from user
        if change<1 or change>(len(listofitems)): #if value is not present
            print("Error: There is no item at that position")
        else: #if value is present
            print("Enter your change:",end='')
            listofitems[change-1]=input() #updating item by index value
    elif menu=='c': #if entered character is c
        print("Which item do you want to check?:",end='')
        change=int(input()) #taking changed value from user
        if change<1 or change>(len(listofitems)):
            print("Error: There is no item at that position")
        else:
            listofitems.pop(change-1) #deleting value from list
            print ("item",end=' ')
            print(change,end=' ')
            print ("was checked and removed")
    elif menu=='?':
        printlist() #calling printlist method
    elif menu=='q':
        print("Good bye")
        break

Sample Output:



Add a comment
Know the answer?
Add Answer to:
A specific question I have on this project is how do I make the stars all...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Q1 (2 pts) Shopping list Write a program that prompts a user for items on their...

    Q1 (2 pts) Shopping list Write a program that prompts a user for items on their shopping list and keeps prompting the user until they enter "Done" (make sure your program can stop even if the user enters "Done" with different cases, like "done"), then prints out the items in the list, line by line, and prints the total number of items on the shopping list. Output (after collecting items in the while loop) should look something like this: Apple...

  • Below is the code for the class shoppingList, I need to enhance it to accomplish the...

    Below is the code for the class shoppingList, I need to enhance it to accomplish the challenge level as stated in the description above. public class ShoppingList {   private java.util.Scanner scan; private String[] list; private int counter; public ShoppingList() { scan = new java.util.Scanner(System.in); list = new String[10]; counter = 0; } public boolean checkDuplicate(String item) { for(int i = 0; i < counter; i++) { if (list[i].equals(item)) return true; } return false; } public void printList() { System.out.println("Your shopping...

  • Write the code in python, if you cannot answer all the question please dont anser, thanx very much. Please gimme a scr...

    Write the code in python, if you cannot answer all the question please dont anser, thanx very much. Please gimme a screen shot for code. Write clear code with comments and follow coding convention. Comments should include your name, student number and subject code on top of your code Question 1 Create a list to store all the subject codes that you are currently doing at UOW Then use for loop to display it in a table as in the...

  • This is a quick little assignment I have to do, but I missed alot of class...

    This is a quick little assignment I have to do, but I missed alot of class due to the Hurricane and no one here knows what theyre doing. please help! this is Java with intelli-J Overview In this project students will build a four-function one-run calculator on the command line. The program will first prompt the user for two numbers, then display a menu with five operations. It will allow the user to select an option by reading input using...

  • Sample Execution – Level 3 Welcome to your Menu Creation system. How many items would you...

    Sample Execution – Level 3 Welcome to your Menu Creation system. How many items would you like to have on your menu? 2 Create your menu! Enter item #1: Coffee Enter the number of toppings: 2 Enter topping #1: Whipped Cream Enter topping #2: Cinnamon Enter item #2: Tea Enter the number of toppings: 2 Enter topping #1: Milk Enter topping #2: Sugar May I take your order? This is the menu: Coffee Tea Pop How many items would you...

  • You are to write a program name Bank.java that maintains a list of records containing names...

    You are to write a program name Bank.java that maintains a list of records containing names and balance of customers. The program will prompt the user for a command, execute the command, then prompt the user for another command. The commands must be chosen from the following possibilities:           a    Show all records           r     Remove the current record           f     Change the first name in the current record           l     Change the last name in the current record           n    Add a new record           d   ...

  • need help in Java Now we’ll continue our project by writing a Facebook class that contains an ArrayList of Facebook user...

    need help in Java Now we’ll continue our project by writing a Facebook class that contains an ArrayList of Facebook user objects. The Facebook class should have methods to list all of the users (i.e. print out their usernames), add a user,delete a user, and get the password hint for a user You will also need to create a driver program. The driver should create an instance of the Facebook class and display a menu containing five options: list users...

  • The purpose of this assignment is to get experience with an array, do while loop and...

    The purpose of this assignment is to get experience with an array, do while loop and read and write file operations. Your goal is to create a program that reads the exam.txt file with 10 scores. After that, the user can select from a 4 choice menu that handles the user’s choices as described in the details below. The program should display the menu until the user selects the menu option quit. The project requirements: It is an important part...

  • Create a python script to manage a user list that can be modified and saved to...

    Create a python script to manage a user list that can be modified and saved to a text file. Input text file consisting of pairs of usernames and passwords, separated by a colon (:) without any spaces User choice: (‘n’-new user account, ‘e’-edit existing user account, ‘d’- delete existing user account, ‘l’- list user accounts, ‘q’-quit) List of user accounts, error messages when appropriate Output text file consisting of pairs of username and passwords, separated by a colon (:) without...

  • This is done in c programming and i have the code for the programs that it wants at the bottom i ...

    This is done in c programming and i have the code for the programs that it wants at the bottom i jut dont know how to call the functions Program 2:Tip,Tax,Total int main(void) {    // Constant and Variable Declarations    double costTotal= 0;    double taxTotal = 0;    double totalBill = 0;    double tipPercent = 0;    // *** Your program goes here ***    printf("Enter amount of the bill: $");    scanf("%lf", &costTotal);    printf("\n");    // *** processing ***    taxTotal = 0.07 * costTotal;    totalBill...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT