Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a 9. Write a function swap(d, key1, key2) that takes a dictionary and two keys and swaps the values corresponding to both keys. If any

image text in transcribed

a 9. Write a function swap(d, key1, key2) that takes a dictionary and two keys and swaps the values corresponding to both keys. If any of the keys is not present in the dictionary, the function should print an error message. Sample Function Calls Sample Return values swap({1:'a', 2: 'b'], 1, 2) swap({1:'a', 2: 'b'}, 1, 3) {1:'b', 2: 'a'} "3 is not a key in the dictionary

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions