[Python] How to iterate and store variables in a dictionary?

Discussão em 'Python' iniciado por Stack, Junho 9, 2025.

  1. Stack

    Stack Membro Participativo

    I am new to python and my coding experience so far is with MATLAB.

    I am trying to understand more about lists and dictionaries as i am using a library about DOEs that takes an dictionary as a passing argument.

    But my trouble so far is that this dictionary assumes the form of ex.

    DOE={'Elastic Modulus':[10,20,30], 'Density':[1,2,3], 'Thickness':[2,3,5]}

    But i need this dictionary to be user defined, for example:


    1. Have an input to define how many variables are needed (in this example are 3: Elastic Modulus','Density'and 'Thickness)


    2. as the variables are defined, it should be able to store values in the dictionary over a for loop.

    Is this possible using dictionaries?

    Or is it better to use a list and convert in a dicionary later?

    Thank you in advance

    Continue reading...

Compartilhe esta Página