Question: I don't know what to do for question 1 and 2. How do I use format with dictionary to compelete the andwer, like those example


I don't know what to do for question 1 and 2.
KeyError: 'pet_name The excersises in this section will combine the above idea with lists and lo Exercises First we need some data, in this case we want to create two diction name and email key: Alice (alice@nyu.edu) and Bob (bob@nyu.edu) Question 1 In [143]: Edit with the values for Alice. entry_1 - ('name': Alice 'email' "alice nyu.edu) Add the keys and values to this entry like above entry_2 = ('name': "Bob", "email': "bobenyu.edu"} YOUR CODE HERE Fraise NotImplementederror() In (146): assert entry_1['name'] - "Alice" In [147]: TEST assert entry_1['name'] - "Alice" In 1: In [149]: print('(o)'.format(entry_1)) Alle lamaibalina a 149]: print('{0}'.format(entry_1)) ('name': 'Alice', 'email': 'alice@nyu.edu) Now we want to write our own message which uses both the 'name' and 'email' values. We are going to use another way to write Python strings, inside triple quote string you can just pressenter for a newline, no n' required. Just write as you would normally in an editor 150]: message - Tey alicenyu.edu) Hey (Alice). How is the weather? print(message) To: {alice@nyu.edu) Hey (Alice), How is the weather? Question 2 Final step, let's format the message with each of the entries. 1511 l in the missing pieces for Alice (entry_1) and Bob (entry 2) respectively formatted_message_Alice - message.format(name - "Alice", email - Walice@nyu.edu) formatted_message_Bob - message.format(name - "Bob", email - "bobenyu.edu) YOUR CODE HERE raise Not ImplementedError() Traceback mont FACA CAL Question 2 Final step, let's format the message with each of the entries. IN 115111 Fill in the missing pieces for Alice (entry...) and Bob entry 2 respectively formatted_message_Alice - message, format (name formatted_message_Bob message. format(name # YOUR CODE HERE Alice email Palice nyu.edu) 'Bob email bobenyu.edu Fraise NotImplementedError() KeyError Traceback (most recent call last
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
