I want to print specific line just one time in for loop using python 3.4
<p>I want to print specific in line just one time in for loop but insted of result in one line it gives same result four time please help me how to stop for loop after printing one line </p>

<p>Here is complete html and python code also with result of this script</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ul class="breadcrumbs" id="BREADCRUMBS"&gt;
  &lt;li class="breadcrumb_item " itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"&gt;
   &lt;a class="breadcrumb_link" href="/Tourism-g191-United_States-Vacations.html" itemprop="url" onclick="ta.setEvtCookie('Breadcrumbs', 'click', 'Country', 1, this.href); "&gt;
       &lt;span itemprop="title"&gt;United States&lt;/span&gt;
   &lt;/a&gt;
   &lt;span class="separator"&gt;âº&lt;/span&gt;
  &lt;/li&gt;
    .
    .
    .
    .</code></pre>
</div>
</div>

Python script which print result</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>ulpart = soup.find_all("ul", {"class": "breadcrumbs"})
    			for unorder in ulpart:
    				div2 = soup.find_all("li", {"class": "breadcrumb_item "})
    				for listitem in div2[0:]:
    					country = soup.select_one("li.breadcrumb_item a[onclick*=Country]").get_text(strip=True)
    					print(country)</code></pre>
</div>
</div>
</p>

<p>Here is result of this code which print same result four time </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>United State
United State
United State
United State</code></pre>
</div>
</div>
</p>

<p>But i want United State just one time like this:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>United State</code></pre>
</div>
</div>
</p>

<p>since you are using unordered lists you can use python set datatype(if you need order use list):</p>

<pre><code>printed = set()

ulpart = soup.find_all("ul", {"class": "breadcrumbs"})
                for unorder in ulpart:
                    div2 = soup.find_all("li", {"class": "breadcrumb_item "})
                    for listitem in div2[0:]:
                        country = soup.select_one("li.breadcrumb_item a[onclick*=Country]").get_text(strip=True)
                        printed.add(country)
</code></pre>

python html html5 python-3.4