Javascript Gets The Value Of The Title Attribute

| | | | | | |

👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!

The HTML

</pre> tag defines the title of a web page. This title appears in the browser tab bar and when you add a page to your favorites list. All web pages must contain a <pre class="prettyprint"><title></pre> tag .</em></p> <p>When you create a web page, you must specify a title for that web page. For example, let’s say you are creating a homepage for a local bakery’s website. You may want the name of the bakery to appear as the title of the web page.</p> <p>This is where the HTML <em><pre class="prettyprint"><title></pre></em> tag comes in. The <em>Tag The <pre class="prettyprint"><title></pre></em> tag defines the title of a document in HTML and is placed in the head section of a web page. This tutorial will cover, with reference to an example, the importance of the <em><pre class="prettyprint"><title></pre></em> tag and how you can use it in your code.</p> <h2> HTML Head Refresher</h2><p>In HTML, the <em><head></em> element is used to store header elements. These elements provide additional information about a web page, such as the icon that should appear for the web page.</p> <p>Together, the elements of the <em><head></em> section describe key information about a document. They can point the browser to stylesheets and scripts used in a document (if used).</p> <h2> HTML <pre class="prettyprint"><title></pre></h2><p>HTML <em><pre class="prettyprint"><title></pre> </em> the tag defines the title of the document. This tag appears inside the <em><head></em> tag. This tag should sum up the purpose of a web page. You just need to specify one <pre class="prettyprint"><title></pre> tag per page.</p> <p>Let’s look at the syntax of this tag:</p>  <p>The <pre class="prettyprint"><title></pre> tag has both an opening tag and a closing tag. Between these tags, we wrote a title for a web page.</p>  </div>  </div>  </a> </div> <p>The text of our <pre class="prettyprint"><title></pre> tag does not appear on the web page. This is because our <pre class="prettyprint"><title></pre> tag is included in the <head> tag instead of the <body> tag on our web page.</p> <p>Our title above is strong because it tells the user exactly what page they are viewing. We have also specified the name of the site, which avoids confusion if a user has multiple tabs open in view with the title "Home".</p> <p>The title should be clear, easy to read and not too long. Consider the following sample headlines:</p> <ul> <li>Blog - Professional Karma</li><li>Contact Professional Karma</li><li>Professional Karma Blog</li></ul>  <p>All these titles express the purpose of the page. it should not be too long because titles only have limited space in the tab bar.</p>  <p>The <pre class="prettyprint"><title></pre> tag supports all global attributes, for example in HTML5. This tag is supported by all major modern browsers. The title tag does not have an element-specific HTML attribute.</p> <h2> Example HTML title tag</h2><p>The HTML title element is defined inside the <em><head> </em> tag on an HTML page. Suppose we are creating a web page for our local bakery, Joseph Abrams & Sons. We are currently building the homepage and we want the name of the pastry shop to appear in the title of the site.</p> <p>We could use the following code to set our page title to " <em>Giuseppe Abrams & Figli. </em> ":</p> <p>When our site’s web page is opened, the page title is set to" <em>Joseph Abrams & Sons</em> ". </p>  </a> </div> <p>Now suppose we create a contact page for our local bakery from before. We could use the title " <em>Contact | Joseph Abrams & Sons</em> & ldquo ;. This title is simple and also describes the purpose of our web page well.</p> <h2> Why should you use a <pre class="prettyprint"><title></pre> tag ?</h2><p>There are a number of reasons specifying a document title tag is important.</p> <p>First, the <em><pre class="prettyprint"><title></pre></em> tag displays the page title in the title bar of your web browser. For example, the title of this page is "<em>HTML Title Tag: A How-To | Python.Engineering</em>.‚" It appears in the tab name of this site.</p>  <p>Second, the <em>tag The <pre class="prettyprint"><title></pre></em> tag labels the web page when it is bookmarked or saved as a favorite in the user’s web browser. The title you specify will be that automatically saved. If you do not use an appropriate title for a web page, a user may have difficulty finding your page in their favorites.</p> <p>Search engines depend on the content of a tag. title. The title specified in a title tag will be the title of the web page on a search engine results page (SERP). The SERP is an entry on a search results page.</p> <p>Additionally, the content of the <em><pre class="prettyprint"><title></pre></em> tag is used to determine the subject of the web page by search engines.</p> <p>So now that we know <em><pre class="prettyprint"><title></pre></em> tags are important, you might be wondering: How to use HTML title tag? Let’s answer this question.</p> <h2> Conclusion</h2><p>The <em><pre class="prettyprint"><title></pre></em> tag indicates the title of an HTML document. This title is displayed in the tab names of the web browser. It is also used by search engines when processing a web page to decide the title and subject.</p>  </a> </div>  <p>This tutorial covered the basics of the HTML <em><pre class="prettyprint"><title></pre></em> tag by referring to an example. You are now ready to start using the title tag as an HTML expert! </p>  <p>Want to learn more about HTML coding ? Check out our <a href="/learn-html/"> HTML Learning Guide </a>. This guide contains a list of the best learning resources and courses for beginners. and intermediate developers. You will also find the best books to read on the subject HTML.</p>   </div>
    <p>
        👻 <em>Read also: what is the <a href="/best-laptop-for-engineering-student/">best laptop for engineering students</a>?</em>
    </p>
    <h2>Javascript Gets The Value Of The Title Attribute exp: Questions</h2>
<div class="question-block">
 <div class="question-block__tags">
<a class="question-block__tag tag" href="https://python.engineering/cat/wiki/exp/">exp</a>
 </div>
    <p class="question-block__title">How do I merge two dictionaries in a single expression (taking union of dictionaries)?</p>
    <p class="question-block__answers"><span>5</span> answers</p>

    <div class="question-block__author">
    <img class="question-block__author-img" src="img/article-author-img.jpg" alt="Carl Meyer">
    <span class="question-block__author-name">By Carl Meyer</span>
    </div>
<p>I have two Python dictionaries, and I want to write a single expression that returns these two dictionaries, merged (i.e. taking the union).  The <code>update()</code> method would be what I need, if it returned its result instead of modifying a dictionary in-place.</p>
<pre><code>>>> x = {"a": 1, "b": 2}
>>> y = {"b": 10, "c": 11}
>>> z = x.update(y)
>>> print(z)
None
>>> x
{"a": 1, "b": 10, "c": 11}
</code></pre>
<p>How can I get that final merged dictionary in <code>z</code>, not <code>x</code>?</p>
<p>(To be extra-clear, the last-one-wins conflict-handling of <code>dict.update()</code> is what I"m looking for as well.)</p>
</div>

                        <div class="answer">
                            <div class="answer__stars">5839</div>
                            <div class="answer__inner">
                                <p class="answer__title">Answer #1</p>
                                <div class="answer__content">
                                    <p><blockquote>
<h2 id="how-can-i-merge-two-python-dictionaries-in-a-single-expression-uwzk">How can I merge two Python dictionaries in a single expression?</h2>
</blockquote>
<p>For dictionaries <code>x</code> and <code>y</code>, <code>z</code> becomes a shallowly-merged dictionary with values from <code>y</code> replacing those from <code>x</code>.</p>
<ul>
<li><p>In Python 3.9.0 or greater (released 17 October 2020): <a href="https://www.python.org/dev/peps/pep-0584/" rel="noreferrer">PEP-584</a>, <a href="https://bugs.python.org/issue36144" rel="noreferrer">discussed here</a>, was implemented and provides the simplest method:</p>
<pre class="lang-py prettyprint-override"><code>z = x | y          # NOTE: 3.9+ ONLY
</code></pre>
</li>
<li><p>In Python 3.5 or greater:</p>
<pre class="lang-py prettyprint-override"><code>z = {**x, **y}
</code></pre>
</li>
<li><p>In Python 2, (or 3.4 or lower) write a function:</p>
<pre class="lang-py prettyprint-override"><code>def merge_two_dicts(x, y):
    z = x.copy()   # start with keys and values of x
    z.update(y)    # modifies z with keys and values of y
    return z
</code></pre>
<p>and now:</p>
<pre class="lang-py prettyprint-override"><code>z = merge_two_dicts(x, y)
</code></pre>
</li>
</ul>
<h3 id="explanation-9ysq">Explanation</h3>
<p>Say you have two dictionaries and you want to merge them into a new dictionary without altering the original dictionaries:</p>
<pre class="lang-py prettyprint-override"><code>x = {"a": 1, "b": 2}
y = {"b": 3, "c": 4}
</code></pre>
<p>The desired result is to get a new dictionary (<code>z</code>) with the values merged, and the second dictionary"s values overwriting those from the first.</p>
<pre class="lang-py prettyprint-override"><code>>>> z
{"a": 1, "b": 3, "c": 4}
</code></pre>
<p>A new syntax for this, proposed in <a href="https://www.python.org/dev/peps/pep-0448" rel="noreferrer">PEP 448</a> and <a href="https://mail.python.org/pipermail/python-dev/2015-February/138564.html" rel="noreferrer">available as of Python 3.5</a>, is</p>
<pre class="lang-py prettyprint-override"><code>z = {**x, **y}
</code></pre>
<p>And it is indeed a single expression.</p>
<p>Note that we can merge in with literal notation as well:</p>
<pre class="lang-py prettyprint-override"><code>z = {**x, "foo": 1, "bar": 2, **y}
</code></pre>
<p>and now:</p>
<pre class="lang-py prettyprint-override"><code>>>> z
{"a": 1, "b": 3, "foo": 1, "bar": 2, "c": 4}
</code></pre>
<p>It is now showing as implemented in the <a href="https://www.python.org/dev/peps/pep-0478/#features-for-3-5" rel="noreferrer">release schedule for 3.5, PEP 478</a>, and it has now made its way into the <a href="https://docs.python.org/dev/whatsnew/3.5.html#pep-448-additional-unpacking-generalizations" rel="noreferrer">What"s New in Python 3.5</a> document.</p>
<p>However, since many organizations are still on Python 2, you may wish to do this in a backward-compatible way. The classically Pythonic way, available in Python 2 and Python 3.0-3.4, is to do this as a two-step process:</p>
<pre class="lang-py prettyprint-override"><code>z = x.copy()
z.update(y) # which returns None since it mutates z
</code></pre>
<p>In both approaches, <code>y</code> will come second and its values will replace <code>x</code>"s values, thus <code>b</code> will point to <code>3</code> in our final result.</p>
<h2 id="not-yet-on-python-3.5-but-want-a-single-expression-zmt4">Not yet on Python 3.5, but want a <em>single expression</em></h2>
<p>If you are not yet on Python 3.5 or need to write backward-compatible code, and you want this in a <em>single expression</em>, the most performant while the correct approach is to put it in a function:</p>
<pre class="lang-py prettyprint-override"><code>def merge_two_dicts(x, y):
    """Given two dictionaries, merge them into a new dict as a shallow copy."""
    z = x.copy()
    z.update(y)
    return z
</code></pre>
<p>and then you have a single expression:</p>
<pre class="lang-py prettyprint-override"><code>z = merge_two_dicts(x, y)
</code></pre>
<p>You can also make a function to merge an arbitrary number of dictionaries, from zero to a very large number:</p>
<pre class="lang-py prettyprint-override"><code>def merge_dicts(*dict_args):
    """
    Given any number of dictionaries, shallow copy and merge into a new dict,
    precedence goes to key-value pairs in latter dictionaries.
    """
    result = {}
    for dictionary in dict_args:
        result.update(dictionary)
    return result
</code></pre>
<p>This function will work in Python 2 and 3 for all dictionaries. e.g. given dictionaries <code>a</code> to <code>g</code>:</p>
<pre class="lang-py prettyprint-override"><code>z = merge_dicts(a, b, c, d, e, f, g) 
</code></pre>
<p>and key-value pairs in <code>g</code> will take precedence over dictionaries <code>a</code> to <code>f</code>, and so on.</p>
<h2 id="critiques-of-other-answers-fxgc">Critiques of Other Answers</h2>
<p>Don"t use what you see in the formerly accepted answer:</p>
<pre class="lang-py prettyprint-override"><code>z = dict(x.items() + y.items())
</code></pre>
<p>In Python 2, you create two lists in memory for each dict, create a third list in memory with length equal to the length of the first two put together, and then discard all three lists to create the dict. <strong>In Python 3, this will fail</strong> because you"re adding two <code>dict_items</code> objects together, not two lists -</p>
<pre class="lang-py prettyprint-override"><code>>>> c = dict(a.items() + b.items())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: "dict_items" and "dict_items"
</code></pre>
<p>and you would have to explicitly create them as lists, e.g. <code>z = dict(list(x.items()) + list(y.items()))</code>. This is a waste of resources and computation power.</p>
<p>Similarly, taking the union of <code>items()</code> in Python 3 (<code>viewitems()</code> in Python 2.7) will also fail when values are unhashable objects (like lists, for example). Even if your values are hashable, <strong>since sets are semantically unordered, the behavior is undefined in regards to precedence. So don"t do this:</strong></p>
<pre class="lang-py prettyprint-override"><code>>>> c = dict(a.items() | b.items())
</code></pre>
<p>This example demonstrates what happens when values are unhashable:</p>
<pre class="lang-py prettyprint-override"><code>>>> x = {"a": []}
>>> y = {"b": []}
>>> dict(x.items() | y.items())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: "list"
</code></pre>
<p>Here"s an example where <code>y</code> should have precedence, but instead the value from <code>x</code> is retained due to the arbitrary order of sets:</p>
<pre class="lang-py prettyprint-override"><code>>>> x = {"a": 2}
>>> y = {"a": 1}
>>> dict(x.items() | y.items())
{"a": 2}
</code></pre>
<p>Another hack you should not use:</p>
<pre class="lang-py prettyprint-override"><code>z = dict(x, **y)
</code></pre>
<p>This uses the <code>dict</code> constructor and is very fast and memory-efficient (even slightly more so than our two-step process) but unless you know precisely what is happening here (that is, the second dict is being passed as keyword arguments to the dict constructor), it"s difficult to read, it"s not the intended usage, and so it is not Pythonic.</p>
<p>Here"s an example of the usage being <a href="https://code.djangoproject.com/attachment/ticket/13357/django-pypy.2.diff" rel="noreferrer">remediated in django</a>.</p>
<p>Dictionaries are intended to take hashable keys (e.g. <code>frozenset</code>s or tuples), but <strong>this method fails in Python 3 when keys are not strings.</strong></p>
<pre class="lang-py prettyprint-override"><code>>>> c = dict(a, **b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: keyword arguments must be strings
</code></pre>
<p>From the <a href="https://mail.python.org/pipermail/python-dev/2010-April/099459.html" rel="noreferrer">mailing list</a>, Guido van Rossum, the creator of the language, wrote:</p>
<blockquote>
<p>I am fine with
declaring dict({}, **{1:3}) illegal, since after all it is abuse of
the ** mechanism.</p>
</blockquote>
<p>and</p>
<blockquote>
<p>Apparently dict(x, **y) is going around as "cool hack" for "call
x.update(y) and return x". Personally, I find it more despicable than
cool.</p>
</blockquote>
<p>It is my understanding (as well as the understanding of the <a href="https://mail.python.org/pipermail/python-dev/2010-April/099485.html" rel="noreferrer">creator of the language</a>) that the intended usage for <code>dict(**y)</code> is for creating dictionaries for readability purposes, e.g.:</p>
<pre class="lang-py prettyprint-override"><code>dict(a=1, b=10, c=11)
</code></pre>
<p>instead of</p>
<pre class="lang-py prettyprint-override"><code>{"a": 1, "b": 10, "c": 11}
</code></pre>
<h2 id="response-to-comments-zkqe">Response to comments</h2>
<blockquote>
<p>Despite what Guido says, <code>dict(x, **y)</code> is in line with the dict specification, which btw. works for both Python 2 and 3. The fact that this only works for string keys is a direct consequence of how keyword parameters work and not a short-coming of dict. Nor is using the ** operator in this place an abuse of the mechanism, in fact, ** was designed precisely to pass dictionaries as keywords.</p>
</blockquote>
<p>Again, it doesn"t work for 3 when keys are not strings. The implicit calling contract is that namespaces take ordinary dictionaries, while users must only pass keyword arguments that are strings. All other callables enforced it. <code>dict</code> broke this consistency in Python 2:</p>
<pre><code>>>> foo(**{("a", "b"): None})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: foo() keywords must be strings
>>> dict(**{("a", "b"): None})
{("a", "b"): None}
</code></pre>
<p>This inconsistency was bad given other implementations of Python (PyPy, Jython, IronPython). Thus it was fixed in Python 3, as this usage could be a breaking change.</p>
<p>I submit to you that it is malicious incompetence to intentionally write code that only works in one version of a language or that only works given certain arbitrary constraints.</p>
<p>More comments:</p>
<blockquote>
<p><code>dict(x.items() + y.items())</code> is still the most readable solution for Python 2. Readability counts.</p>
</blockquote>
<p>My response: <code>merge_two_dicts(x, y)</code> actually seems much clearer to me, if we"re actually concerned about readability. And it is not forward compatible, as Python 2 is increasingly deprecated.</p>
<blockquote>
<p><code>{**x, **y}</code> does not seem to handle nested dictionaries. the contents of nested keys are simply overwritten, not merged [...] I ended up being burnt by these answers that do not merge recursively and I was surprised no one mentioned it. In my interpretation of the word "merging" these answers describe "updating one dict with another", and not merging.</p>
</blockquote>
<p>Yes. I must refer you back to the question, which is asking for a <em>shallow</em> merge of <em><strong>two</strong></em> dictionaries, with the first"s values being overwritten by the second"s - in a single expression.</p>
<p>Assuming two dictionaries of dictionaries, one might recursively merge them in a single function, but you should be careful not to modify the dictionaries from either source, and the surest way to avoid that is to make a copy when assigning values. As keys must be hashable and are usually therefore immutable, it is pointless to copy them:</p>
<pre class="lang-py prettyprint-override"><code>from copy import deepcopy

def dict_of_dicts_merge(x, y):
    z = {}
    overlapping_keys = x.keys() & y.keys()
    for key in overlapping_keys:
        z[key] = dict_of_dicts_merge(x[key], y[key])
    for key in x.keys() - overlapping_keys:
        z[key] = deepcopy(x[key])
    for key in y.keys() - overlapping_keys:
        z[key] = deepcopy(y[key])
    return z
</code></pre>
<p>Usage:</p>
<pre class="lang-py prettyprint-override"><code>>>> x = {"a":{1:{}}, "b": {2:{}}}
>>> y = {"b":{10:{}}, "c": {11:{}}}
>>> dict_of_dicts_merge(x, y)
{"b": {2: {}, 10: {}}, "a": {1: {}}, "c": {11: {}}}
</code></pre>
<p>Coming up with contingencies for other value types is far beyond the scope of this question, so I will point you at <a href="https://stackoverflow.com/a/24088493/541136">my answer to the canonical question on a "Dictionaries of dictionaries merge"</a>.</p>
<h2 id="less-performant-but-correct-ad-hocs-zrgm">Less Performant But Correct Ad-hocs</h2>
<p>These approaches are less performant, but they will provide correct behavior.
They will be <em>much less</em> performant than <code>copy</code> and <code>update</code> or the new unpacking because they iterate through each key-value pair at a higher level of abstraction, but they <em>do</em> respect the order of precedence (latter dictionaries have precedence)</p>
<p>You can also chain the dictionaries manually inside a <a href="https://www.python.org/dev/peps/pep-0274/" rel="noreferrer">dict comprehension</a>:</p>
<pre class="lang-py prettyprint-override"><code>{k: v for d in dicts for k, v in d.items()} # iteritems in Python 2.7
</code></pre>
<p>or in Python 2.6 (and perhaps as early as 2.4 when generator expressions were introduced):</p>
<pre class="lang-py prettyprint-override"><code>dict((k, v) for d in dicts for k, v in d.items()) # iteritems in Python 2
</code></pre>
<p><code>itertools.chain</code> will chain the iterators over the key-value pairs in the correct order:</p>
<pre class="lang-py prettyprint-override"><code>from itertools import chain
z = dict(chain(x.items(), y.items())) # iteritems in Python 2
</code></pre>
<h2 id="performance-analysis-c4us">Performance Analysis</h2>
<p>I"m only going to do the performance analysis of the usages known to behave correctly. (Self-contained so you can copy and paste yourself.)</p>
<pre class="lang-py prettyprint-override"><code>from timeit import repeat
from itertools import chain

x = dict.fromkeys("abcdefg")
y = dict.fromkeys("efghijk")

def merge_two_dicts(x, y):
    z = x.copy()
    z.update(y)
    return z

min(repeat(lambda: {**x, **y}))
min(repeat(lambda: merge_two_dicts(x, y)))
min(repeat(lambda: {k: v for d in (x, y) for k, v in d.items()}))
min(repeat(lambda: dict(chain(x.items(), y.items()))))
min(repeat(lambda: dict(item for d in (x, y) for item in d.items())))
</code></pre>
<p>In Python 3.8.1, NixOS:</p>
<pre class="lang-py prettyprint-override"><code>>>> min(repeat(lambda: {**x, **y}))
1.0804965235292912
>>> min(repeat(lambda: merge_two_dicts(x, y)))
1.636518670246005
>>> min(repeat(lambda: {k: v for d in (x, y) for k, v in d.items()}))
3.1779992282390594
>>> min(repeat(lambda: dict(chain(x.items(), y.items()))))
2.740647904574871
>>> min(repeat(lambda: dict(item for d in (x, y) for item in d.items())))
4.266070580109954
</code></pre>
<pre class="lang-sh prettyprint-override"><code>$ uname -a
Linux nixos 4.19.113 #1-NixOS SMP Wed Mar 25 07:06:15 UTC 2020 x86_64 GNU/Linux
</code></pre>
<h2 id="resources-on-dictionaries-e74r">Resources on Dictionaries</h2>
<ul>
<li><a href="https://stackoverflow.com/questions/327311/how-are-pythons-built-in-dictionaries-implemented/44509302#44509302">My explanation of Python"s <strong>dictionary implementation</strong>, updated for 3.6.</a></li>
<li><a href="https://stackoverflow.com/questions/1024847/add-new-keys-to-a-dictionary/27208535#27208535">Answer on how to add new keys to a dictionary</a></li>
<li><a href="https://stackoverflow.com/questions/209840/map-two-lists-into-a-dictionary-in-python/33737067#33737067">Mapping two lists into a dictionary</a></li>
<li><a href="https://docs.python.org/3/tutorial/datastructures.html#dictionaries" rel="noreferrer">The official Python docs on dictionaries</a></li>
<li><a href="https://www.youtube.com/watch?v=66P5FMkWoVU" rel="noreferrer">The Dictionary Even Mightier</a> - talk by Brandon Rhodes at Pycon 2017</li>
<li><a href="https://www.youtube.com/watch?v=npw4s1QTmPg" rel="noreferrer">Modern Python Dictionaries, A Confluence of Great Ideas</a> - talk by Raymond Hettinger at Pycon 2017</li>
</ul></p>
                                </div>
                            </div>
                        </div>
                        
                        <div class="answer">
                            <div class="answer__stars">5839</div>
                            <div class="answer__inner">
                                <p class="answer__title">Answer #2</p>
                                <div class="answer__content">
                                    <p><p>In your case, what you can do is:</p>
<pre class="lang-py prettyprint-override"><code>z = dict(list(x.items()) + list(y.items()))
</code></pre>
<p>This will, as you want it, put the final dict in <code>z</code>, and make the value for key <code>b</code> be properly overridden by the second (<code>y</code>) dict"s value:</p>
<pre class="lang-py prettyprint-override"><code>>>> x = {"a":1, "b": 2}
>>> y = {"b":10, "c": 11}
>>> z = dict(list(x.items()) + list(y.items()))
>>> z
{"a": 1, "c": 11, "b": 10}

</code></pre>
<p>If you use Python 2, you can even remove the <code>list()</code> calls. To create z:</p>
<pre class="lang-py prettyprint-override"><code>>>> z = dict(x.items() + y.items())
>>> z
{"a": 1, "c": 11, "b": 10}
</code></pre>
<p>If you use Python version 3.9.0a4 or greater, then you can directly use:</p>
<pre class="lang-py prettyprint-override"><code>x = {"a":1, "b": 2}
y = {"b":10, "c": 11}
z = x | y
print(z)
</code></pre>
<pre class="lang-py prettyprint-override"><code>{"a": 1, "c": 11, "b": 10}
</code></pre></p>
                                </div>
                            </div>
                        </div>
                        
                        <div class="answer">
                            <div class="answer__stars">5839</div>
                            <div class="answer__inner">
                                <p class="answer__title">Answer #3</p>
                                <div class="answer__content">
                                    <p><p>An alternative:</p>

<pre><code>z = x.copy()
z.update(y)
</code></pre></p>
                                </div>
                            </div>
                        </div>
                        
<div class="question-block">
 <div class="question-block__tags">
<a class="question-block__tag tag" href="https://python.engineering/cat/wiki/find/">find</a>
 </div>
    <p class="question-block__title">Finding the index of an item in a list</p>
    <p class="question-block__answers"><span>5</span> answers</p>
<p>Given a list <code>["foo", "bar", "baz"]</code> and an item in the list <code>"bar"</code>, how do I get its index (<code>1</code>) in Python?</p>
</div>

                        <div class="answer">
                            <div class="answer__stars">3740</div>
                            <div class="answer__inner">
                                <p class="answer__title">Answer #1</p>
                                <div class="answer__content">
                                    <p><pre><code>>>> ["foo", "bar", "baz"].index("bar")
1
</code></pre>
<p>Reference: <a href="https://docs.python.org/tutorial/datastructures.html#more-on-lists" rel="noreferrer">Data Structures > More on Lists</a></p>
<h1>Caveats follow</h1>
<p>Note that while this is perhaps the cleanest way to answer the question <em>as asked</em>, <code>index</code> is a rather weak component of the <code>list</code> API, and I can"t remember the last time I used it in anger. It"s been pointed out to me in the comments that because this answer is heavily referenced, it should be made more complete. Some caveats about <code>list.index</code> follow. It is probably worth initially taking a look at the documentation for it:</p>
<blockquote>
<pre><code>list.index(x[, start[, end]])
</code></pre>
<p>Return zero-based index in the list of the first item whose value is equal to <em>x</em>. Raises a <a href="https://docs.python.org/library/exceptions.html#ValueError" rel="noreferrer"><code>ValueError</code></a> if there is no such item.</p>
<p>The optional arguments <em>start</em> and <em>end</em> are interpreted as in the <a href="https://docs.python.org/tutorial/introduction.html#lists" rel="noreferrer">slice notation</a> and are used to limit the search to a particular subsequence of the list. The returned index is computed relative to the beginning of the full sequence rather than the start argument.</p>
</blockquote>
<h2>Linear time-complexity in list length</h2>
<p>An <code>index</code> call checks every element of the list in order, until it finds a match. If your list is long, and you don"t know roughly where in the list it occurs, this search could become a bottleneck. In that case, you should consider a different data structure. Note that if you know roughly where to find the match, you can give <code>index</code> a hint. For instance, in this snippet, <code>l.index(999_999, 999_990, 1_000_000)</code> is roughly five orders of magnitude faster than straight <code>l.index(999_999)</code>, because the former only has to search 10 entries, while the latter searches a million:</p>
<pre><code>>>> import timeit
>>> timeit.timeit("l.index(999_999)", setup="l = list(range(0, 1_000_000))", number=1000)
9.356267921015387
>>> timeit.timeit("l.index(999_999, 999_990, 1_000_000)", setup="l = list(range(0, 1_000_000))", number=1000)
0.0004404920036904514
 
</code></pre>
<h2>Only returns the index of the <em>first match</em> to its argument</h2>
<p>A call to <code>index</code> searches through the list in order until it finds a match, and <em>stops there.</em> If you expect to need indices of more matches, you should use a list comprehension, or generator expression.</p>
<pre><code>>>> [1, 1].index(1)
0
>>> [i for i, e in enumerate([1, 2, 1]) if e == 1]
[0, 2]
>>> g = (i for i, e in enumerate([1, 2, 1]) if e == 1)
>>> next(g)
0
>>> next(g)
2
</code></pre>
<p>Most places where I once would have used <code>index</code>, I now use a list comprehension or generator expression because they"re more generalizable. So if you"re considering reaching for <code>index</code>, take a look at these excellent Python features.</p>
<h2>Throws if element not present in list</h2>
<p>A call to <code>index</code> results in a <a href="https://docs.python.org/library/exceptions.html#ValueError" rel="noreferrer"><code>ValueError</code></a> if the item"s not present.</p>
<pre><code>>>> [1, 1].index(2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: 2 is not in list
</code></pre>
<p>If the item might not be present in the list, you should either</p>
<ol>
<li>Check for it first with <code>item in my_list</code> (clean, readable approach), or</li>
<li>Wrap the <code>index</code> call in a <code>try/except</code> block which catches <code>ValueError</code> (probably faster, at least when the list to search is long, and the item is usually present.)</li>
</ol></p>
                                </div>
                            </div>
                        </div>
                        
                        <div class="answer">
                            <div class="answer__stars">3740</div>
                            <div class="answer__inner">
                                <p class="answer__title">Answer #2</p>
                                <div class="answer__content">
                                    <p><p>One thing that is really helpful in learning Python is to use the interactive help function:</p>

<pre><code>>>> help(["foo", "bar", "baz"])
Help on list object:

class list(object)
 ...

 |
 |  index(...)
 |      L.index(value, [start, [stop]]) -> integer -- return first index of value
 |
</code></pre>

<p>which will often lead you to the method you are looking for.</p></p>
                                </div>
                            </div>
                        </div>
                        
                        <div class="answer">
                            <div class="answer__stars">3740</div>
                            <div class="answer__inner">
                                <p class="answer__title">Answer #3</p>
                                <div class="answer__content">
                                    <p><p>The majority of answers explain how to find <strong>a single index</strong>, but their methods do not return multiple indexes if the item is in the list multiple times. Use <a href="https://docs.python.org/library/functions.html#enumerate" rel="noreferrer"><code>enumerate()</code></a>:</p>

<pre><code>for i, j in enumerate(["foo", "bar", "baz"]):
    if j == "bar":
        print(i)
</code></pre>

<p>The <code>index()</code> function only returns the first occurrence, while <code>enumerate()</code> returns all occurrences.</p>

<p>As a list comprehension:</p>

<pre><code>[i for i, j in enumerate(["foo", "bar", "baz"]) if j == "bar"]
</code></pre>

<hr>

<p>Here"s also another small solution with <a href="http://docs.python.org/library/itertools.html#itertools.count" rel="noreferrer"><code>itertools.count()</code></a> (which is pretty much the same approach as enumerate):</p>

<pre><code>from itertools import izip as zip, count # izip for maximum efficiency
[i for i, j in zip(count(), ["foo", "bar", "baz"]) if j == "bar"]
</code></pre>

<p>This is more efficient for larger lists than using <code>enumerate()</code>:</p>

<pre><code>$ python -m timeit -s "from itertools import izip as zip, count" "[i for i, j in zip(count(), ["foo", "bar", "baz"]*500) if j == "bar"]"
10000 loops, best of 3: 174 usec per loop
$ python -m timeit "[i for i, j in enumerate(["foo", "bar", "baz"]*500) if j == "bar"]"
10000 loops, best of 3: 196 usec per loop
</code></pre></p>
                                </div>
                            </div>
                        </div>
                        



                   </div>
                </div>
                <div class="article__right">
                    <div class="hub_ad">
                        <div id="ezoic-pub-ad-placeholder-106">
                          <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9381065361874746"
                               crossorigin="anonymous"></script>
                          <!-- PYE aside NEW -->
                          <ins class="adsbygoogle"
                               style="display:block"
                               data-ad-client="ca-pub-9381065361874746"
                               data-ad-slot="8755532771"
                               data-ad-format="auto"
                               data-full-width-responsive="true"></ins>
                          <script>
                               (adsbygoogle = window.adsbygoogle || []).push({});
                          </script>  
                        </div>                   
                    </div>
                    <div class="shop-aside shop-aside--mt">
                        <h2 class="shop-aside__title">Shop</h2>
                        <div class="shop__items shop__items--column">
                             	
                            <div class="shop__item"><a class="shop__item-link" href="https://python.engineering/learn-programming-in-r-courses/"></a><img class="shop__item-img" src="">
                                <p class="shop__item-name">Learn programming in R: courses</p><span class="shop__item-price">$</span>
                            </div>
                             	
                            <div class="shop__item"><a class="shop__item-link" href="https://python.engineering/best-python-online-courses-for-2022/"></a><img class="shop__item-img" src="">
                                <p class="shop__item-name">Best Python online courses for 2022</p><span class="shop__item-price">$</span>
                            </div>
                             	
                            <div class="shop__item"><a class="shop__item-link" href="https://python.engineering/best-laptop-for-fortnite/"></a><img class="shop__item-img" src="">
                                <p class="shop__item-name">Best laptop for Fortnite</p><span class="shop__item-price">$</span>
                            </div>
                             	
                            <div class="shop__item"><a class="shop__item-link" href="https://python.engineering/best-laptop-for-excel/"></a><img class="shop__item-img" src="">
                                <p class="shop__item-name">Best laptop for Excel</p><span class="shop__item-price">$</span>
                            </div>
                             	
                            <div class="shop__item"><a class="shop__item-link" href="https://python.engineering/best-laptop-for-solidworks/"></a><img class="shop__item-img" src="">
                                <p class="shop__item-name">Best laptop for Solidworks</p><span class="shop__item-price">$</span>
                            </div>
                             	
                            <div class="shop__item"><a class="shop__item-link" href="https://python.engineering/best-laptop-for-roblox/"></a><img class="shop__item-img" src="">
                                <p class="shop__item-name">Best laptop for Roblox</p><span class="shop__item-price">$</span>
                            </div>
                             	
                            <div class="shop__item"><a class="shop__item-link" href="https://python.engineering/best-computer-for-crypto-mining/"></a><img class="shop__item-img" src="">
                                <p class="shop__item-name">Best computer for crypto mining</p><span class="shop__item-price">$</span>
                            </div>
                             	
                            <div class="shop__item"><a class="shop__item-link" href="https://python.engineering/best-laptop-for-sims-4/"></a><img class="shop__item-img" src="http://python.engineering/wp-content/uploads/2022/04/pye-best-laptop-for-sims-4.jpg">
                                <p class="shop__item-name">Best laptop for Sims 4</p><span class="shop__item-price">$</span>
                            </div>
                            
                        </div>
                    </div>

                    <div class="hub_ad">
                        <div id="ezoic-pub-ad-placeholder-106" style="position:sticky; position:-webkit-sticky; top:0; margin-top:10px; z-index: 1000">
                          <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9381065361874746"
                               crossorigin="anonymous"></script>
                          <!-- PYE aside NEW -->
                          <ins class="adsbygoogle"
                               style="display:block"
                               data-ad-client="ca-pub-9381065361874746"
                               data-ad-slot="8755532771"
                               data-ad-format="auto"
                               data-full-width-responsive="true"></ins>
                          <script>
                               (adsbygoogle = window.adsbygoogle || []).push({});
                          </script>  
                        </div>                   
                    </div>


                    <div class="l-questions l-questions--mt">
                        <p class="l-questions__title">Latest questions</p>
                        <div class="l-questions__list">
                       
                        <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/8134602-psycopg2-insert-multiple-rows-with-one-query/"></a>
                            <div class="l-questions__item-tags"><span class="l-questions__item-tag violet">NUMPY</span><span class="l-questions__item-tag yellow">NUMPY</span></div>
                            <p class="l-questions__item-title">psycopg2: insert multiple rows with one query</p>
                            <p class="l-questions__item-answers"><span>12</span> answers</p>
                        </div>
                       
                        <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/3930188-how-to-convert-nonetype-to-int-or-string/"></a>
                            <div class="l-questions__item-tags"><span class="l-questions__item-tag violet">NUMPY</span><span class="l-questions__item-tag yellow">NUMPY</span></div>
                            <p class="l-questions__item-title">How to convert Nonetype to int or string?</p>
                            <p class="l-questions__item-answers"><span>12</span> answers</p>
                        </div>
                       
                        <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/33945261-how-to-specify-multiple-return-types-using-type-hints/"></a>
                            <div class="l-questions__item-tags"><span class="l-questions__item-tag violet">NUMPY</span><span class="l-questions__item-tag yellow">NUMPY</span></div>
                            <p class="l-questions__item-title">How to specify multiple return types using type-hints</p>
                            <p class="l-questions__item-answers"><span>12</span> answers</p>
                        </div>
                       
                        <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/51922480-javascript-error-ipython-is-not-defined-in-jupyterlab/"></a>
                            <div class="l-questions__item-tags"><span class="l-questions__item-tag violet">NUMPY</span><span class="l-questions__item-tag yellow">NUMPY</span></div>
                            <p class="l-questions__item-title">Javascript Error: IPython is not defined in JupyterLab</p>
                            <p class="l-questions__item-answers"><span>12</span> answers</p>
                        </div>
                        
                        </div>
                        <div class="l-questions__more-link"><a href="/cat/wiki/so/">All questions</a></div>
                    </div>
                    <div class="hub_ad">
                        <div id="ezoic-pub-ad-placeholder-106" style="position:sticky; position:-webkit-sticky; top:0; margin-top:10px; z-index: 1000">
                          <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9381065361874746"
                               crossorigin="anonymous"></script>
                          <!-- PYE aside NEW -->
                          <ins class="adsbygoogle"
                               style="display:block"
                               data-ad-client="ca-pub-9381065361874746"
                               data-ad-slot="8755532771"
                               data-ad-format="auto"
                               data-full-width-responsive="true"></ins>
                          <script>
                               (adsbygoogle = window.adsbygoogle || []).push({});
                          </script>  
                        </div>                   
                    </div>                    
                </div>
            </div>
        </div>
    </div>



<!-- news -->
    <div class="news">
        <div class="container">
            <h2 class="news__title h2">News</h2>
            <div class="news__items">

   
            <!--
            <a class="news__item" href="https://python.engineering/famous-programmers-and-developers-cooler-than-rock-stars-and-movie-actors/" style="background-image: url('https://python.engineering/wp-content/uploads/2022/09/pye-famous-29-09-2022.jpeg')">
            -->
            <a class="news__item" href="https://python.engineering/famous-programmers-and-developers-cooler-than-rock-stars-and-movie-actors/" style="background-color: #243978;">
                <span class="news__item-overlay">
                  <span class="news__item-cat">29/09/2022</span>
                  <span class="news__item-title">Famous programmers and developers: cooler than rock stars and movie actors</span>
                </span>
            </a>
   
            <!--
            <a class="news__item" href="https://python.engineering/what-employers-expect-from-a-junior-python-developer/" style="background-image: url('https://python.engineering/wp-content/uploads/2022/09/bcc-junior-python-26-09-2022.jpeg')">
            -->
            <a class="news__item" href="https://python.engineering/what-employers-expect-from-a-junior-python-developer/" style="background-color: #243978;">
                <span class="news__item-overlay">
                  <span class="news__item-cat">26/09/2022</span>
                  <span class="news__item-title">What Employers Expect from a Junior Python Developer</span>
                </span>
            </a>
   
            <!--
            <a class="news__item" href="https://python.engineering/python-vs-r-what-should-a-beginner-data-scientist-choose/" style="background-image: url('https://python.engineering/wp-content/uploads/2022/09/pye-R-25-09-2022.jpeg')">
            -->
            <a class="news__item" href="https://python.engineering/python-vs-r-what-should-a-beginner-data-scientist-choose/" style="background-color: #243978;">
                <span class="news__item-overlay">
                  <span class="news__item-cat">25/09/2022</span>
                  <span class="news__item-title">Python vs. R: what should a beginner Data Scientist choose?</span>
                </span>
            </a>
              
            </div>
        </div>
    </div>
<!-- /new -->

<br>

<!-- wiki -->
    <div class="wiki">
        <div class="container">
            <h2 class="wiki__title h2">Wiki</h2>
            <div class="wiki-grid">
               
                <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/python-opencv-cv2-puttext-method/"></a>
                    <div class="l-questions__item-tags">
                      <a href=""><span class="l-questions__item-tag violet">__del__</span></a>
                    </div>
                    <p class="l-questions__item-title">Python OpenCV | cv2.putText () method</p>
                </div>
               
                <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/numpy-arctan2-python/"></a>
                    <div class="l-questions__item-tags">
                      <a href=""><span class="l-questions__item-tag violet">__del__</span></a>
                    </div>
                    <p class="l-questions__item-title">numpy.arctan2 () in Python</p>
                </div>
               
                <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/python-os-path-realpath-method/"></a>
                    <div class="l-questions__item-tags">
                      <a href=""><span class="l-questions__item-tag violet">__del__</span></a>
                    </div>
                    <p class="l-questions__item-title">Python | os.path.realpath () method</p>
                </div>
               
                <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/python-opencv-cv2-circle-method/"></a>
                    <div class="l-questions__item-tags">
                      <a href=""><span class="l-questions__item-tag violet">around</span></a>
                    </div>
                    <p class="l-questions__item-title">Python OpenCV | cv2.circle () method</p>
                </div>
               
                <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/python-opencv-cv2-cvtcolor-method/"></a>
                    <div class="l-questions__item-tags">
                      <a href=""><span class="l-questions__item-tag violet">cvtcolor</span></a>
                    </div>
                    <p class="l-questions__item-title">Python OpenCV cv2.cvtColor () method</p>
                </div>
               
                <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/python-move-element-to-end-of-the-list/"></a>
                    <div class="l-questions__item-tags">
                      <a href=""><span class="l-questions__item-tag violet">Python functions</span></a>
                    </div>
                    <p class="l-questions__item-title">Python - Move item to the end of the list</p>
                </div>
               
                <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/time-perf_counter-function-in-python/"></a>
                    <div class="l-questions__item-tags">
                      <a href=""><span class="l-questions__item-tag violet">Counters</span></a>
                    </div>
                    <p class="l-questions__item-title">time.perf_counter () function in Python</p>
                </div>
               
                <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/python-check-if-one-list-is-subset-of-other/"></a>
                    <div class="l-questions__item-tags">
                      <a href=""><span class="l-questions__item-tag violet">__dict__</span></a>
                    </div>
                    <p class="l-questions__item-title">Check if one list is a subset of another in Python</p>
                </div>
               
                <div class="l-questions__item"><a class="l-questions__item-link" href="https://python.engineering/python-os-path-join-method/"></a>
                    <div class="l-questions__item-tags">
                      <a href=""><span class="l-questions__item-tag violet">__del__</span></a>
                    </div>
                    <p class="l-questions__item-title">Python os.path.join () method</p>
                </div>
                
            </div>
        </div>
    </div>     
<!-- /wiki -->   






<!-- new footer -->
    <footer class="footer">
        <div class="container">
            <div class="footer__row">
                <div class="footer__left"><img class="footer__logo" src="/wp-content/themes/nimani/img/footer-logo.svg" alt="Python Engineering">
                    <p class="footer__copyright">© 2017—2022 <br> Python Engineering Hub</p>

                    <p class="footer__desc">
<a href="/cat/wiki/" class="footer__nav-link">EN</a> | <a href="/cat/es_sp/" class="footer__nav-link">ES</a> | <a href="/cat/de_de/" class="footer__nav-link">DE</a> | <a href="/cat/fr_fr/" class="footer__nav-link">FR</a> | <a href="/cat/it_it/" class="footer__nav-link">IT</a> | <a href="/cat/ru_ru/" class="footer__nav-link">RU</a> | <a href="/cat/tr_tr/" class="footer__nav-link">TR</a> | <a href="/cat/pl_pl/" class="footer__nav-link">PL</a> | <a href="/cat/pt_pt/" class="footer__nav-link">PT</a> | <a href="/cat/ja_jp/" class="footer__nav-link">JP</a> | <a href="/cat/ko_kr/" class="footer__nav-link">KR</a> | <a href="/cat/zh_cn/" class="footer__nav-link">CN</a> | <a href="/cat/hi_in/" class="footer__nav-link">HI</a> | <a href="/cat/nl_nl/" class="footer__nav-link">NL</a>
                    </p>   
                    <br>                    
                    <p class="footer__desc">
                    Python.Engineering is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com
                    </p>

                </div>
                <div class="footer__nav-col">
                    <p class="footer__nav-title">Python</p>
                    <ul class="footer__nav-list">
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/loops/">Loops</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/counters/">Counters</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/numpy/">NumPy</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/nlp/">NLP</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/regex/">Regular Expressions</a></li>
                    </ul>
                </div>
                <div class="footer__nav-col">
                    <p class="footer__nav-title">Wiki</p>
                    <ul class="footer__nav-list">
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/news/">Tech news</a></li>                        
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/wiki/">Python Wiki</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/wiki/so/">StackOverflow</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/php/">PHP</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/javascript/">JavaScript</a></li>
                    </ul>
                </div>
                <div class="footer__nav-col">
                    <p class="footer__nav-title">Books</p>
                    <ul class="footer__nav-list">
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/books/">All books</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/computations/">Computations</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/development/">Development</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/cryptography/">Cryptography</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/beginners/">For dummies</a></li>
                        <li class="footer__nav-item"><a class="footer__nav-link" href="/cat/bigdata/">Big Data</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </footer>
    <script src="https://code.jquery.com/jquery-3.5.0.min.js"></script>
    <script src="/wp-content/themes/nimani/js/libs.js"></script>
    <script src="/wp-content/themes/nimani/js/index.js"></script>
    <script src="/wp-content/themes/nimani/js/vendor/lazysizes.min.js" async></script>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-Q022WLXW4X" async></script>
    <script async src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?autoload=true&skin=desert&lang=python"></script>
    <script type="text/javascript">
        document.addEventListener("DOMContentLoaded", () => {
            let arrayCode = document.querySelectorAll('pre');
            arrayCode.forEach(element => {
                element.classList.add("prettyprint");
            });
        });        
    </script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-Q022WLXW4X');
    </script>


<!-- ===================== LEAVE POPUP ===================== 

    <script src="/wp-content/themes/nimani/js/ouibounce.js"></script>
    <script>
      // if you want to use the 'fire' or 'disable' fn,
      // you need to save OuiBounce to an object
      var _ouibounce = ouibounce(document.getElementById('ouibounce-modal'), {
        aggressive: true,
        timer: 0,
        delay: 1000,
        callback: function() { console.log('ouibounce fired!'); }
      });

      $('body').on('click', function() {
        $('#ouibounce-modal').hide();
      });

      $('#ouibounce-modal .modal-footer').on('click', function() {
        $('#ouibounce-modal').hide();
      });

      $('#ouibounce-modal .modal').on('click', function(e) {  e.stopPropagation();});
    </script>

    <script>
    $("#reload_form_button" ).click(function() {
        console.log("hui");
    $('#reload_form').load('/wp-content/themes/nimani/af.html');
    });
    </script>
    
 ===================== /LEAVE POPUP ===================== -->


</body>

</html>
<!-- /new footer -->