Create class using dictionary | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Create class using dictionary

Guys is there a way to convert a dictionary into a class without knowing the attributes of the class at first. For eg: Profile_dic = { 'Name' = 'Steve' , 'Age' = 25} Now use the above dictionary to create a class assuming I didn't know at first I would include the above keys and then store each profile created into a separate value in a new dictionary "All_profiles" with numbered keys as I did in the below code. I stored a class to a dictionary using the below code: https://code.sololearn.com/cr9ORpRoVCnl/?ref=app

18th May 2020, 3:34 PM
Mathew
1 Answer
20th May 2020, 8:54 AM
Wasi
Wasi - avatar