Convert list to variables in python 3 -
i using easygui list of integers user. outputs this:
fieldvalues = [1,2] i want convert list to:
var1 = 1 var2 = 2
(edited explain reasoning more clearly)
one reason why might want convert list variables make code more self-documenting. variable password easier understand fieldvalue[3], instance.
however, @blender suggested, better not assign elements of list individual variables.
one way achieve both goals refer elements of list name rather number. in other languages, use enumerated variable (e.g. enum in java or c#). use enum package in python robust solution or this:
username, password = range(2) print(fieldvalue[username])
Comments
Post a Comment