Test if dict contained in dict

0 votes
I have these 2 dicts:

a  = {1:"abc", 2:"xyz", 3:"efg"}
b = {1:"abc", 2:"xyz", 3:"trois", 4:"bar"}

I want to test if a is a subset of b. What should i do?
Jul 2, 2019 by Nisa
• 1,090 points
168 views

1 answer to this question.

0 votes

You can use the following piece of code to check your condition:

EXAMPLE:

a  = {1:"abc", 2:"xyz", 3:"efg"}
b = {1:"abc", 2:"xyz", 3:"tro", 4:"bar"}
if a.items() <= b.items():
    print("a is subset of b")
else:
    print("a is not a subset of b")

OUTPUT:

a is not a subset of b


answered Jul 2, 2019 by Wajiha
• 1,960 points

Related Questions

0 votes
1 answer

How to stop test execution in Selenium if an error occured?

Hey Fatima, if you are using any ...READ MORE

answered Jul 4, 2019 in Selenium by Abha
• 28,140 points
11,370 views
+1 vote
1 answer

Disable notification" “Chrome is being controlled by automated test software” in ChromeDriver 2.36

"disable-infobars" flag has been deprecated, but you ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,500 points
17,510 views
0 votes
2 answers

"Train" and "Test" sets in Data Science

Normally to perform supervised learning you need ...READ MORE

answered Aug 3, 2018 in Data Analytics by Abhi
• 3,720 points
1,506 views
0 votes
2 answers

Can anyone help me that how to run Selenium WebDriver test cases in Chrome?

You first need to download chrome driver ...READ MORE

answered Aug 26, 2019 in Selenium by Abha
• 28,140 points
2,082 views
0 votes
1 answer

Reading data from Excel in my Selenium test

Log4j problems are usually thrown because of ...READ MORE

answered Apr 6, 2018 in Selenium by nsv999
• 5,500 points
10,742 views
+1 vote
2 answers

Can I include real world data in a smart contract? If so, how?

You cant access/embed real world data using ...READ MORE

answered Jul 18, 2018 in Blockchain by sapan
1,366 views
0 votes
3 answers

Check if a String is numeric in Java

Java 8 Lambda Expression is used: String someString ...READ MORE

answered Sep 3, 2018 in Java by Daisy
• 8,140 points
3,846 views
0 votes
1 answer

Check if the object(variable) is defined in R

You can use the exists(): > exists("toFindUnknown") [1] FALSE > ...READ MORE

answered Apr 17, 2018 in Data Analytics by Sahiti
• 6,370 points
847 views
0 votes
1 answer

What is the difference between if() and require() statement in solidity??

If() and require() have separate functions and ...READ MORE

answered Apr 18, 2018 in Blockchain by Shashank
• 10,400 points
5,143 views
+1 vote
2 answers

What if I delete default VPC in AWS?What are the consequences?

If you wish to recreate the default ...READ MORE

answered Apr 20, 2018 in Cloud Computing by DragonLord999
• 8,450 points
6,360 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP