how do i equate raw input with a variable value in python
<p>This is my first 'program' or script or whatev. So if I am going about this completely wrong, feel free to make fun of me.<br>
I wanted to make a textual, player vs player chess program.<br>
My first instinct was to make the board an 8x8 list of lists like [[a1,a2...a8]...[h1,h2...h8]], but was unsure how to attach values to the items in the list, such as a flag for occupied or unoccupied.<br>
Then I had the idea to try each square as a separate value that holds its status like a1 = wr (for white rook) and a3 = o (for open) and after successful moves just update the values of the squares.<br>
My first instinct was to take the user input like   </p>

<pre><code>move = raw_input("enter your move")  
</code></pre>

<p>and the user would enter:<br>
e4 for example<br>
I then wanted to do something like:  </p>

<pre><code>if move == "o"  
</code></pre>

<p>to make sure the square would be open<br>
I think its obvious what I am TRYING to do, but I understand why it doesnt work.<br>
is there some way to cast the raw_input as a variable so that:  </p>

<pre><code>move == o returns TRUE if the variable e4 is o  
</code></pre>

<p>?<br>
edit:<br>
for the actual code, it is really only in my head at this point but here is a shot:  </p>

<pre><code>a1=wr  
a2=wp  
a3=o  
a4=o  
a5=o  
a6=o  
a7=bp  
a8=br  
</code></pre>

<p>and so on for the remainder files   </p>

<pre><code>move = raw_input("enter your move: ")  
</code></pre>

<p>-----this program is mainly for me, so I am not checking input I would just enter a move like: e4 </p>

<pre><code>if move == o:  
  then e4 = wp  
  else print "illegal move, square is occupied"  
</code></pre>

<p>I realize that the variable 'move' points to the string 'e4' and the variable e4 points to string 'o' and that these are separate and different entities, but is there some way to take the string input and check to see if there is a variable with the same 'name'?  </p>

<p>awesome thanks for all the great answers...</p>
