In my requirement the list is dynamically creating with collection of dictionaries with different columns for each time. So every time what I need to print will be different based on the some logic.
If I create if ..else statement for each case I can print what ever I want.
Here I have too many cases so I dont want to write that many if ...esle statements just to print.
Instead of that I want to read what I need to print from a config file and print the actual value.
Example: list1=[{'name': 'xyz', 'age' : 22, 'place' : 'huj'}, {'name' : 'hjhd", 'age' : 44, 'place' : 'wer'}]
want to print name and age columns
the following code will do my work.
if id == 1:
for i in list1:
i['name']+","+i['age']
elif id == 2:
for i in list1:
i['account']+","+i['spend']
elif id == 3:
for i in list1:
i['percentage']+","+i['rank']
I just want to write only one if else statement. Since I have more than 100 cases.
Instead of writing these many if else statements is there any other way I can handle this by using ConfigParser or any thing else.