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
37 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,930 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
• 27,720 points
790 views
+2 votes
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,510 points
2,706 views
0 votes
2 answers

"Train" and "Test" sets in Data Science

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

answered Aug 2, 2018 in Data Analytics by Anmol
• 3,680 points
79 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
• 27,720 points
385 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,510 points
5,897 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 17, 2018 in Blockchain by sapan
84 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,080 points
991 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,290 points
66 views
+1 vote
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,360 points
549 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,400 points
249 views