I'm not able to pass the values of a list to a for
loop which will return the value assigned to it in config file at runtime.
My config file is demo.ini
:
[DEMFILE]
Name='XYZABC'
Surname='TYUIO'
Code='123'
City='Kolkata'
I have a list in which I have parameters like below:
from configparser import ConfigParser
mylist=['Name','Code']
mylist_count=len(mylist)
dmfg=config_object["DEMFILE"]
for i in range(mylist_count):
getValue=dmfg[i] # ---> Throws error
print(f'The value of {i} is : {getValue}')
Expected Output for getValue
is as shown below:
The value of Name is : XYZABC
The value of City is : Kolkata
I want whatever the values in list that should check in config file and return the output assigned to it.
For example: Name
--> XYZABC
(coming from config file).