How can I evaluate variable to another variable before assigning?
Posted
by
HH
on Stack Overflow
See other posts from Stack Overflow
or by HH
Published on 2011-01-04T03:30:37Z
Indexed on
2011/01/04
3:53 UTC
Read the original article
Hit count: 182
#!/usr/bin/python
#
# Description: trying to evaluate array -value to variable before assignment
# but it overwrites the variable
#
# How can I evaluate before assigning on the line 16?
#Initialization, dummy code?
x=0
y=0
variables = [x, y]
data = ['2,3,4', '5,5,6']
# variables[0] should be evaluted to `x` here, i.e. x = data[0], how?
variables[0] = data[0]
if ( variables[0] != x ):
print("It does not work, why?");
else:
print("It works!");
© Stack Overflow or respective owner