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 by Nisa
• 1,090 points
29 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 by Wajiha
• 1,920 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 in Selenium by Abha
• 27,180 points
341 views
0 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,110 points
2,044 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,620 points
62 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 in Selenium by Abha
• 27,180 points
315 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,110 points
5,224 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
73 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,050 points
827 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 darklord
• 6,170 points
59 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,350 points
456 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,380 points
172 views