Using BeautifulSoup with multiple tags with the same name
<p>I have the below html</p>

<pre><code>&lt;g class="1581 sqw_sv5" style="cursor: pointer;"&gt;
 &lt;path d="M397.696,126.554C397.696,126.554,404.57504,140.2417375,404.57504,140.2417375" stroke="#ffffff" style="stroke-width: 3.6; stroke-opacity: 0.5; stroke-linecap: round; fill-opacity: 0;"&gt;
 &lt;/path&gt;
 &lt;path d="M397.696,126.554C397.696,126.554,404.57504,140.2417375,404.57504,140.2417375" stroke="#f95a0b" style="stroke-width: 1.2; stroke-linecap: round; fill-opacity: 0;"&gt;
 &lt;/path&gt;
</code></pre>

<p>I need to obtain the value of the 'stroke' in the second <em>path</em>. My current code is only pulling the value from the first <em>path</em>.</p>

<p>I am currently using</p>

<pre><code>shots = soup.find_all('g')
for shot in shots:
    print(shot.path['stroke'])
</code></pre>

<p>which returns #ffffff. I need it to return #f95a0b</p>

<p>Here's my solution to your question.  My issue with my answer is that it may be overly specific.  This will only work if the value of <code>style</code> is always <code>"stroke-width: 1.2; stroke-linecap: round; fill-opacity: 0;"</code> and if only one such <code>path</code> element is present in the entire document.</p>

<p>The idea behind this solution is to quickly narrow down the elements by looking for what's unique to the desired element containing the desired attribute.</p>

<pre><code>`
from bs4 import BeautifulSoup

html = """"&lt;g class="1581 sqw_sv5" style="cursor: pointer;"&gt;
 &lt;path d="M397.696,126.554C397.696,126.554,404.57504,140.2417375,404.57504,140.2417375" stroke="#ffffff" style="stroke-width: 3.6; stroke-opacity: 0.5; stroke-linecap: round; fill-opacity: 0;"&gt;
 &lt;/path&gt;
 &lt;path d="M397.696,126.554C397.696,126.554,404.57504,140.2417375,404.57504,140.2417375" stroke="#f95a0b" style="stroke-width: 1.2; stroke-linecap: round; fill-opacity: 0;"&gt;
 &lt;/path&gt;"""

soup = BeautifulSoup(html, "html.parser")
# get the desired 'path' element using the 'style' that identifies it
desired_element =  soup.find("path", {"style" : "stroke-width: 1.2; stroke-linecap: round; fill-opacity: 0;"})
# get the attribute value from the extracted element
desired_attribute = desired_element["stroke"]
print (desired_attribute)
# prints #f95a0b
`
</code></pre>

<p>If this approach is a no go, then you may have to use BeautifulSoups's <code>next_sibling</code> or <code>findNext</code> methods. Basically look for the first path element, which you are currently accomplishing with your code, then 'jump' from there to the next path element, which contains what you need.</p>

<p>findNext: <a href="https://stackoverflow.com/questions/5999747/beautifulsoup-nextsibling">Beautifulsoup - nextSibling</a></p>

<p>next_sibling: <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/#next-sibling-and-previous-sibling" rel="nofollow">https://www.crummy.com/software/BeautifulSoup/bs4/doc/#next-sibling-and-previous-sibling</a></p>

python beautifulsoup