Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
Python question: how do I add an item into a cart from a dictionary I created when asking the user for their input? I know for lists if the item the user is asking for is in the list say then it wil be added into said cart, but how would it work for dictionaries?
lists_books = [Journey to the west, Samurai showdown, Guitar methods]
user_lists = []
while lists_books > 1
if user_lists == lists_books
cart.update
return cart.items
.
(sorry for the horrible list example code) How would it work for dictionaries to add an item to a cart?
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 1 images
Knowledge Booster
Similar questions
- numUniqueValues ♡ Language/Type: Related Links: Java Set collections List Write a method named numUnique Values that accepts a List of integers as a parameter and returns the number of unique integer values in the list. For example, if a list named 1 contains the values [3, 7, 3, -1, 2, 3, 7, 2, 15, 15], the call of numUniqueValues (1) should return 5. If passed the empty list, you should return 0. Use a Set as auxiliary storage to help you solve this problem. Do not modify the list passed in. 6 7 8 9 10 Method: Write a Java method as described, not a complete program or class. 12345arrow_forwardIf you perform the following sequence of operations on a list that contains items [2, 4, 6, 8], what will be the output of the last dequeue operation? enqueue(2) enqueue(4) dequeue() enqueue(6) dequeue()arrow_forwardYou can create an empty dictionary with dictionary() [ ] ( ) { } This data structure stores a collection of objects in an unordered manner where each object must be unique dictionary set tuple listarrow_forward
- IN PYTHON THANK YOUarrow_forwardWhat do you mean by a list that is linked twice?arrow_forwardhelp with python code import time timeStamp = time.ctime()print(timeStamp)forum_list = [ {'date':'10-01-2022', 'name':'Student1', 'comment':'Very helpful'}, {'date': '10-01-2022', 'name': 'Student2', 'comment': 'Very good'} ] menu = """ Forum Comments 0: Exit 1: Display Comments 2: Add Comment """ done = False while not done: print(menu) selection = input('Please make a selection: ') if selection == "0": done = True print('Exiting now, thank you for participating') if selection == "1": for d in forum_list: print(d['date'], end='') print(' ', end='') print(d['name']) print(d['comment']) if selection == "2": comment = {} comment['date'] = input('Please enter date: ') comment['name'] = input('Please enter name: ') comment['comment'] = input('Please enter comment: ') forum_list.append(comment) # what's inside the data.txt file #Date Name…arrow_forward
- In pyton: In this lab, you will be building a software application that removes duplicate values from a list.The purpose of the assignment isto gain experience with user-defined functions, forloop and listmanipulation. Start Start of remove duplicate function (numbers: list of numbers) Initialize an empty list as new_list Loop over each of the number of the numbers list If number not in new_list Append number to new_list Return new_list End of remove duplicate functionStart main function Prompt user for list of numbers Call remove duplicate function Print the new list returned by the remove function End of main functionEndarrow_forwardPython Suppose a list empList consists of sublists with [id,fullName] empList = [ ] Ask the user to enter their ID and name Put that information into empList Ask the user to enter a name Print the ID of the person with that name OR “Name not found” if that name isn’t in empList. Ask the user to enter a IDRemove that entry from empList OR print “No delete – name not found” if the ID isn’t there. Ask the user to enter an ID.If empList has an entry with that ID, ask the user for a newFullName and replace the existing entry in empList Print the entries in List, one per line so that the output looks like this:ID Name123 Joe Brown235 Molly Smith Please use format to do this printingarrow_forwardCreat a void fuction void myUpdate(string dictionary[], int wordCount, string oldWord, string newWord); Where it will replace the oldWord with the newWord, if the search is successfularrow_forward
- Debug the program debug_me.py. The program should test each of the users in the provided list. · If the list is empty, it should print “There are no users.” · If the user is “Admin,” the program should print “Hello all powerful one.” · Otherwise, for normal users, it should print “You are a normal user.” Test the program with an empty list to confirm correct operation for that case.arrow_forwardImplement the following: Given: person = {'name': 'bob'}1) Add the key/value pair 'emplStatus': 'Retired' to the dictionary person.2) Access the values in the dictionary person to print the following. Example OutputBob's employment status is Retired. NEED HELP WITH PYTHONarrow_forwardFor any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a comma (no spaces). Ex: If the input is: 32 105 101 35 10 20 30 40 the output is: 20,30, 1 #include 2 3 int main(void) { const int SIZE_LIST = 4; int keysList[SIZE_LIST]; int itemsList[SIZE_LIST]; int i; 4 6 7 8 scanf("%d", &keysList[0]); scanf ("%d", &keysList[1]); scanf("%d", &keysList[2]); scanf("%d", &keysList[3]); 10 11 12 13 scanf ("%d", &itemsList[0]); scanf ("%d", &itemsList[1]); scanf("%d", &itemsList[2]); scanf ("%d", &itemsList[3]); 14 15 16 17 18 19 /* Your code goes here */ 20 21 printf("\n"); 22 23 return 0; 24 }arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY