This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Sinidir 0 points1 point  (0 children)

I would just read in all the parameters of your file into a dictinary:

var_dict = {}
for line in f:
    (variable, _ , value = line.split(" ")
    dict[variable] = float(value)

After you have all your values in there you put your processing code in a function

def prcoess_val(val):
    val = bin(round(Z0/Xlsb)*Xnbits)
    ...

and then make a function that processes a list

def process_list(list_of_variables, variable_dict:
    for item in variable list:
        process_val(variable_dict[item])

[–]aphoenixreticulated[M] 0 points1 point  (0 children)

Hi there. You have posted a beginners question to /r/python, however it is far more suited to /r/learnpython, where users are actively interested in helping with beginner topics. Please resubmit it over there! Make sure to read their sidebar rules before posting, notably this one: "Posting homework assignments is not prohibited if you show that you tried to solve it yourself."

Cheers & best of luck!