Iterate through list and assign a value to the variable in Python -


so i'm working on code, solves simple differentials. code looks that:

deff diff(): coeffs = [] #checking rank of function lvl = int(raw_input("tell me rank of function: ")) if lvl == 0:     print "\nif rank 0, differential of function 0" #asking user write coefficients (like 4x^2 - writes 4) in range(0, lvl):     coeff = int(raw_input("tell me coefficient: "))     coeffs.append(coeff) #printing coefficients print "\nso coefficients are: " item in coeffs:     print item   

and want next? have every coefficient in coeffs[] list. want take every single 1 there , assign different variable, make use of it. , how can it? suppose have use loop, tried hours - nothing helped me. sooo, how can this? : a=coeff[0], b = coeff[1], ..., x = coeff[lvl] .

just access coefficients directly list via indices.

if wanting use values in different context entails making changes values want keep original list unchanged copy list new list,

import copy  mutablecoeffs = copy.copy(coeffs) 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -