I was wondering if I was on the right track with this. I have a table with fields that contain addresses like this:
515 S WEBER RD APT 108 LOCKPORT, IL 60441<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
I'm interested in finding three types of values if they exist, and I'd like to update the value to a new field called 'UnitType'. Right now, this is printing empty brackets. I'm not too sure why.
fc <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'C:\Users\jpilbeam\Downloads\AddPts_AptUnitSte.gdb\Default.gdb\AddPts_AptUnitSte'</SPAN>
field <SPAN class="operator token">=</SPAN> <SPAN class="string token">'USPS_ADDRE'</SPAN>
values <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'Apt'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Unit'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Ste'</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># Use SearchCursor with list comprehension to return a</SPAN>
<SPAN class="comment token"># unique set of values in the specified field</SPAN>
v <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN> field<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
types <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> v <SPAN class="keyword token">if</SPAN> i <SPAN class="keyword token">in</SPAN> values<SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>types<SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</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>