I'm working on a project in which I'm trying to utilize user input in order to search an attribute table for a city. If the city is not present in the table, I want to have a secondary response. So far, I've been using a searchCursor followed by a for loop and then an if statement. If I use a single If statement, I am able to achieve a single response. But if I include a second conditional statement, be it an elif an else or a second if, the script goes through the whole table and gives me a response for each row. Ideally, I would like it to give me a single response (ie. "Yes, its in the table", "No its not in the table"). I'm relatively new to arcGIS, and even newer to Python. Below is my sample text. Any help would be greatly appreciated.
<SPAN class="comment token">#import necessary tools</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env
<SPAN class="keyword token">import</SPAN> sys
<SPAN class="comment token">#set workspace</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'C:\Data'</SPAN> <SPAN class="comment token">#generic source for data</SPAN>
<SPAN class="comment token">#inquire user input</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Please search for a city in New Mexico within 10 Miles of an Amtrak Station."</SPAN>
userInput <SPAN class="operator token">=</SPAN> raw_input <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Which city would you like to check? "</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#establish the SearchCursor</SPAN>
citySearch <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'CitiesAmtrak.shp'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'NAME'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#create a loop to utilize SearchCursor and provide feedback</SPAN>
<SPAN class="keyword token">for</SPAN> column <SPAN class="keyword token">in</SPAN> citySearch<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> userInput <SPAN class="keyword token">in</SPAN> column<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"This city is within 10 miles of an Amtrak Station."</SPAN>
<SPAN class="keyword token">break</SPAN>
<SPAN class="keyword token">if</SPAN> userInput <SPAN class="operator token">not</SPAN> <SPAN class="keyword token">in</SPAN> column<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"no"</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>