Skip to content
Advertisement

I have variables and values in __init__ method and I want to make a new dict in another method where the variable as key and values of it as value

I have this–

JavaScript

I want —

JavaScript

how to use instance variable as key value in another r method

Advertisement

Answer

Magic methods __dict__ can help you

JavaScript

Output

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement