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
15 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,120 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
• 16,440 points
23 views
0 votes
1 answer
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
33 views
0 votes
1 answer

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

Download the executable driver from: ChromeDriver Download Before ...READ MORE

answered Mar 29, 2018 in Selenium by nsv999
• 5,050 points
180 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,050 points
3,038 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
45 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,040 points
557 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,140 points
32 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,330 points
300 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
89 views