I am new to python object oriented programming. I am trying to solve a problem where I have to define a class , create a method , write the code inside it and then create a object and call that method. I am a little confused on how to go forward with it.
Example : {1:’A’,2:’B}
L : [1,2,3,4]
Find the dictionary keys that are present in the list (without using for loop)
>Solution :
Another simple approach can be to use intersection():
my_dict = {1: 'A', 2: 'B'}
my_list = [1, 2, 3, 4]
output = set(my_dict).intersection(my_list)
print(output)