Question: Write the function is _ nested which takes a dictionary and returns a boolean value. Return True if the given dictionary is a nested dictionary;

Write the function is_nested which takes a dictionary and returns a boolean value. Return True if the given dictionary is a nested dictionary; return False if not. For the purposes of this exercise, a nested dictionary is any dictionary with a list, tuple, or dictionary as a value.
Test Case 1
Using the given dictionary and function call below:
# test code below
if __name__=="__main__":
example_dict ={
1 : 'one',
2 : 'two',
3 : 'three'
}
print(is_nested(example_dict))
Your script should print:
False
TRY IT
Test Case 2
Using the given dictionary and function call below:
# test code below
if __name__=="__main__":
example_dict ={
1 : (2,3),
4 : 'four',
5 : 'five'
}
print(is_nested(example_dict))
Your script should print:
True
TRY IT
Test Case 3
Using the given dictionary and function call below:
# test code below
if __name__=="__main__":
example_dict ={
1 : 'one',
2 : {3 : 4},
5 : 'five'
}
print(is_nested(example_dict))
Your script should print:
True
TRY IT
Test Case 4
Using the given dictionary and function call below:
# test code below
if __name__=="__main__":
example_dict ={
1 : 'one',
2 : 'two',
3 : [4,5]
}
print(is_nested(example_dict))
Your script should print:
True
TRY IT

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!