title: LXML/Python - Looping over a list of lxml.etree._Element
body: <p>I'm trying to loop over a list of 5 lxml._Element.</p>
  
  <p>Here is an extract of the part of the html I'm interested in:</p>
  
  <pre><code>    &lt;div style="" id="ember140" class="pv-deferred-area ember-view"&gt;  &lt;div class="pv-deferred-area__content"&gt;
          &lt;!----&gt;
  
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="oc-background-section" class="pv-oc ember-view"&gt;              &lt;span class="background-details"&gt;
                &lt;div id="ember217" class="ember-view"&gt;&lt;section id="ember218" class="pv-profile-section pv-profile-section--reorder-enabled background-section artdeco-container-card ember-view"&gt;&lt;div id="ember219" class="pv-profile-section-pager ember-view"&gt;    &lt;section id="experience-section" class="pv-profile-section experience-section ember-view"&gt;&lt;header class="pv-profile-section__card-header"&gt;
    &lt;h2 class="pv-profile-section__card-heading"&gt;
      Expérience
    &lt;/h2&gt;
  
  &lt;a data-control-name="add_position" href="/in/gregoire-de-kermel/edit/position/new/" id="ember221" class="pv-profile-section__header-add-action add-position artdeco-button artdeco-button--tertiary artdeco-button--circle ember-view"&gt;      &lt;li-icon type="plus-icon" role="img" aria-label="Ajouter un nouveau poste"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" data-supported-dps="24x24" fill="currentColor" width="24" height="24" focusable="false"&gt;
    &lt;path d="M21 13h-8v8h-2v-8H3v-2h8V3h2v8h8v2z"&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/li-icon&gt;
  &lt;/a&gt;&lt;/header&gt;
  
  
    &lt;ul class="pv-profile-section__section-info section-info pv-profile-section__section-info--has-more"&gt;
  &lt;li id="ember223" class="pv-entity__position-group-pager pv-profile-section__list-item ember-view"&gt;        &lt;section id="1571672557" class="pv-profile-section__card-item-v2 pv-profile-section pv-position-entity ember-view"&gt;  &lt;div class="display-flex justify-space-between full-width"&gt;
      &lt;div class="display-flex flex-column full-width"&gt;
  &lt;a data-control-name="background_details_company" href="/company/reputation-squad/" id="ember226" class="full-width ember-view"&gt;          &lt;div class="pv-entity__logo company-logo"&gt;
    &lt;img src="https://media-exp1.licdn.com/dms/image/C4D0BAQE__TgCl2fyUw/company-logo_100_100/0?e=1593648000&amp;amp;v=beta&amp;amp;t=VLSKEVUbJDcULtQwEdrHrH5Gxwq_j7tk2HczgAKn7YU" loading="lazy" alt="Reputation Squad" id="ember228" class="pv-entity__logo-img EntityPhoto-square-5 lazy-image loaded ember-view"&gt;
  &lt;/div&gt;
  &lt;div class="pv-entity__summary-info pv-entity__summary-info--background-section "&gt;
    &lt;h3 class="t-16 t-black t-bold"&gt;Data Scientist&lt;/h3&gt;
    &lt;p class="visually-hidden"&gt;Nom de l’entreprise&lt;/p&gt;
    &lt;p class="pv-entity__secondary-title t-14 t-black t-normal"&gt;
        Reputation Squad
          &lt;span class="pv-entity__secondary-title separator"&gt;Contrat en alternance&lt;/span&gt;
    &lt;/p&gt;
      &lt;div class="display-flex"&gt;
      &lt;h4 class="pv-entity__date-range t-14 t-black--light t-normal"&gt;
        &lt;span class="visually-hidden"&gt;Dates d’emploi&lt;/span&gt;
        &lt;span&gt;janv. 2020 – Aujourd’hui&lt;/span&gt;
      &lt;/h4&gt;
        &lt;h4 class="t-14 t-black--light t-normal"&gt;
          &lt;span class="visually-hidden"&gt;Durée d’emploi&lt;/span&gt;
          &lt;span class="pv-entity__bullet-item-v2"&gt;4 mois&lt;/span&gt;
        &lt;/h4&gt;
    &lt;/div&gt;
  
    &lt;h4 class="pv-entity__location t-14 t-black--light t-normal block"&gt;
      &lt;span class="visually-hidden"&gt;Lieu&lt;/span&gt;
      &lt;span&gt;Région de Paris, France&lt;/span&gt;
    &lt;/h4&gt;
  
  &lt;!----&gt;
  &lt;/div&gt;
  
  &lt;/a&gt;
  &lt;!----&gt;    &lt;/div&gt;
  
        &lt;div class="pv-entity__actions"&gt;
  &lt;a data-control-name="edit_position" href="/in/gregoire-de-kermel/edit/position/1571672557/" id="ember230" class="pv-profile-section__edit-action pv-profile-section__hoverable-action artdeco-button artdeco-button--tertiary artdeco-button--circle ember-view"&gt;          &lt;li-icon type="pencil-icon" role="img" aria-label="Modifier le poste Data Scientist"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" data-supported-dps="24x24" fill="currentColor" width="24" height="24" focusable="false"&gt;
    &lt;path d="M21.71 5L19 2.29a1 1 0 00-.71-.29 1 1 0 00-.7.29L4 15.85 2 22l6.15-2L21.71 6.45a1 1 0 00.29-.74 1 1 0 00-.29-.71zM6.87 18.64l-1.5-1.5L15.92 6.57l1.5 1.5zM18.09 7.41l-1.5-1.5 1.67-1.67 1.5 1.5z"&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/li-icon&gt;
  &lt;/a&gt;&lt;!----&gt;      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;
  &lt;/li&gt;&lt;li id="ember232" class="pv-entity__position-group-pager pv-profile-section__list-item ember-view"&gt;        &lt;section id="1516596236" class="pv-profile-section__card-item-v2 pv-profile-section pv-position-entity ember-view"&gt;  &lt;div class="display-flex justify-space-between full-width"&gt;
      &lt;div class="display-flex flex-column full-width"&gt;
  &lt;a data-control-name="background_details_company" href="/company/credit-agricole-de-la-touraine-et-du-poitou-crto-/" id="ember235" class="full-width ember-view"&gt;          &lt;div class="pv-entity__logo company-logo"&gt;
    &lt;img src="https://media-exp1.licdn.com/dms/image/C560BAQHz0qZ2RutURA/company-logo_100_100/0?e=1593648000&amp;amp;v=beta&amp;amp;t=uzqwKV9Un5c_b7X3Xo7vqA2KXcQkmBRDWpMUO5Bu1Gc" loading="lazy" alt="Crédit Agricole de la Touraine et du Poitou" id="ember237" class="pv-entity__logo-img EntityPhoto-square-5 lazy-image loaded ember-view"&gt;
  &lt;/div&gt;
  &lt;div class="pv-entity__summary-info pv-entity__summary-info--background-section mb2"&gt;
    &lt;h3 class="t-16 t-black t-bold"&gt;Data Scientist&lt;/h3&gt;
    &lt;p class="visually-hidden"&gt;Nom de l’entreprise&lt;/p&gt;
    &lt;p class="pv-entity__secondary-title t-14 t-black t-normal"&gt;
        Crédit Agricole de la Touraine et du Poitou
          &lt;span class="pv-entity__secondary-title separator"&gt;Contrat en alternance&lt;/span&gt;
    &lt;/p&gt;
      &lt;div class="display-flex"&gt;
      &lt;h4 class="pv-entity__date-range t-14 t-black--light t-normal"&gt;
        &lt;span class="visually-hidden"&gt;Dates d’emploi&lt;/span&gt;
        &lt;span&gt;sept. 2019 – janv. 2020&lt;/span&gt;
      &lt;/h4&gt;
        &lt;h4 class="t-14 t-black--light t-normal"&gt;
          &lt;span class="visually-hidden"&gt;Durée d’emploi&lt;/span&gt;
          &lt;span class="pv-entity__bullet-item-v2"&gt;5 mois&lt;/span&gt;
        &lt;/h4&gt;
    &lt;/div&gt;
  
    &lt;h4 class="pv-entity__location t-14 t-black--light t-normal block"&gt;
      &lt;span class="visually-hidden"&gt;Lieu&lt;/span&gt;
      &lt;span&gt;Région de Poitiers, France&lt;/span&gt;
    &lt;/h4&gt;
  
  &lt;!----&gt;
  &lt;/div&gt;
  
  &lt;/a&gt;
          &lt;div id="ember239" class="pv-entity__extra-details t-14 t-black--light ember-view"&gt;&lt;p style="line-height:2rem;max-height:8rem;" id="ember240" class="pv-entity__description t-14 t-black t-normal inline-show-more-text inline-show-more-text--is-collapsed ember-view"&gt;• Web scraping (Python)&lt;br&gt;• Etude de profilage client (SAS)&lt;br&gt;• Mise en place d'un projet de système de recommandation (Hadoop, SAS, Python)
  
  &lt;!----&gt;&lt;/p&gt;&lt;!----&gt;&lt;/div&gt;
      &lt;/div&gt;
  
        &lt;div class="pv-entity__actions"&gt;
  &lt;a data-control-name="edit_position" href="/in/gregoire-de-kermel/edit/position/1516596236/" id="ember241" class="pv-profile-section__edit-action pv-profile-section__hoverable-action artdeco-button artdeco-button--tertiary artdeco-button--circle ember-view"&gt;          &lt;li-icon type="pencil-icon" role="img" aria-label="Modifier le poste Data Scientist"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" data-supported-dps="24x24" fill="currentColor" width="24" height="24" focusable="false"&gt;
    &lt;path d="M21.71 5L19 2.29a1 1 0 00-.71-.29 1 1 0 00-.7.29L4 15.85 2 22l6.15-2L21.71 6.45a1 1 0 00.29-.74 1 1 0 00-.29-.71zM6.87 18.64l-1.5-1.5L15.92 6.57l1.5 1.5zM18.09 7.41l-1.5-1.5 1.67-1.67 1.5 1.5z"&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/li-icon&gt;
  &lt;/a&gt;&lt;!----&gt;      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;
  &lt;/li&gt;&lt;li id="ember243" class="pv-entity__position-group-pager pv-profile-section__list-item ember-view"&gt;        &lt;section id="1427380111" class="pv-profile-section__card-item-v2 pv-profile-section pv-position-entity ember-view"&gt;  &lt;div class="display-flex justify-space-between full-width"&gt;
      &lt;div class="display-flex flex-column full-width"&gt;
  &lt;a data-control-name="background_details_company" href="/company/weblagence/" id="ember246" class="full-width ember-view"&gt;          &lt;div class="pv-entity__logo company-logo"&gt;
    &lt;img src="https://media-exp1.licdn.com/dms/image/C560BAQHOw0tfMPSiWA/company-logo_100_100/0?e=1593648000&amp;amp;v=beta&amp;amp;t=NqZ8eTVFqA2MK4B1ZFUSE7NgTL_ZPqBIMrexzcYnNok" loading="lazy" alt="WebL'Agence" id="ember248" class="pv-entity__logo-img EntityPhoto-square-5 lazy-image loaded ember-view"&gt;
  &lt;/div&gt;
  &lt;div class="pv-entity__summary-info pv-entity__summary-info--background-section mb2"&gt;
    &lt;h3 class="t-16 t-black t-bold"&gt;Python &amp;amp; React Native developer junior&lt;/h3&gt;
    &lt;p class="visually-hidden"&gt;Nom de l’entreprise&lt;/p&gt;
    &lt;p class="pv-entity__secondary-title t-14 t-black t-normal"&gt;
        WebL'Agence
  &lt;!----&gt;  &lt;/p&gt;
      &lt;div class="display-flex"&gt;
      &lt;h4 class="pv-entity__date-range t-14 t-black--light t-normal"&gt;
        &lt;span class="visually-hidden"&gt;Dates d’emploi&lt;/span&gt;
        &lt;span&gt;janv. 2019 – août 2019&lt;/span&gt;
      &lt;/h4&gt;
        &lt;h4 class="t-14 t-black--light t-normal"&gt;
          &lt;span class="visually-hidden"&gt;Durée d’emploi&lt;/span&gt;
          &lt;span class="pv-entity__bullet-item-v2"&gt;8 mois&lt;/span&gt;
        &lt;/h4&gt;
    &lt;/div&gt;
  
    &lt;h4 class="pv-entity__location t-14 t-black--light t-normal block"&gt;
      &lt;span class="visually-hidden"&gt;Lieu&lt;/span&gt;
      &lt;span&gt;Région de Paris, France&lt;/span&gt;
    &lt;/h4&gt;
  
  &lt;!----&gt;
  &lt;/div&gt;
  
  &lt;/a&gt;
          &lt;div id="ember250" class="pv-entity__extra-details t-14 t-black--light ember-view"&gt;&lt;p style="line-height:2rem;max-height:8rem;" id="ember251" class="pv-entity__description t-14 t-black t-normal inline-show-more-text inline-show-more-text--is-collapsed ember-view"&gt;• Création d’applications mobiles (React-Native)&lt;br&gt;• Développement d’un modèle d’évaluation de startup «&amp;nbsp;early-stage&amp;nbsp;»&lt;br&gt;• Web scraping (Selenium Python)&lt;br&gt;• Gestionnaire d’un projet de Machine-Learing/OCR+ (externalisation auprès de prestataires externes et utilisation de AWS textract)
  
      &lt;span class="inline-show-more-text__link-container-collapsed"&gt;
          &lt;span&gt;…&lt;/span&gt;
        &lt;button class="inline-show-more-text__button link" aria-expanded="false" data-ember-action="" data-ember-action-341="341"&gt;
          voir plus
        &lt;/button&gt;
      &lt;/span&gt;
  
  &lt;!----&gt;&lt;/p&gt;&lt;!----&gt;&lt;/div&gt;
      &lt;/div&gt;
  
        &lt;div class="pv-entity__actions"&gt;
  &lt;a data-control-name="edit_position" href="/in/gregoire-de-kermel/edit/position/1427380111/" id="ember252" class="pv-profile-section__edit-action pv-profile-section__hoverable-action artdeco-button artdeco-button--tertiary artdeco-button--circle ember-view"&gt;          &lt;li-icon type="pencil-icon" role="img" aria-label="Modifier le poste Python &amp;amp;amp; React Native developer junior"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" data-supported-dps="24x24" fill="currentColor" width="24" height="24" focusable="false"&gt;
    &lt;path d="M21.71 5L19 2.29a1 1 0 00-.71-.29 1 1 0 00-.7.29L4 15.85 2 22l6.15-2L21.71 6.45a1 1 0 00.29-.74 1 1 0 00-.29-.71zM6.87 18.64l-1.5-1.5L15.92 6.57l1.5 1.5zM18.09 7.41l-1.5-1.5 1.67-1.67 1.5 1.5z"&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/li-icon&gt;
  &lt;/a&gt;&lt;!----&gt;      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;
  &lt;/li&gt;&lt;li id="ember254" class="pv-entity__position-group-pager pv-profile-section__list-item ember-view"&gt;        &lt;section id="708026390" class="pv-profile-section__card-item-v2 pv-profile-section pv-position-entity ember-view"&gt;  &lt;div class="display-flex justify-space-between full-width"&gt;
      &lt;div class="display-flex flex-column full-width"&gt;
  &lt;a data-control-name="background_details_company" href="/search/results/all/?keywords=Gauthier%20Associ%C3%A9s" id="ember257" class="full-width ember-view"&gt;          &lt;div class="pv-entity__logo company-logo"&gt;
    &lt;img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" loading="lazy" alt="Gauthier Associés" id="ember259" class="pv-entity__logo-img EntityPhoto-square-5 lazy-image ghost-company loaded ember-view"&gt;
  &lt;/div&gt;
  &lt;div class="pv-entity__summary-info pv-entity__summary-info--background-section mb2"&gt;
    &lt;h3 class="t-16 t-black t-bold"&gt;Business Financial Analyst&lt;/h3&gt;
    &lt;p class="visually-hidden"&gt;Nom de l’entreprise&lt;/p&gt;
    &lt;p class="pv-entity__secondary-title t-14 t-black t-normal"&gt;
        Gauthier Associés
  &lt;!----&gt;  &lt;/p&gt;
      &lt;div class="display-flex"&gt;
      &lt;h4 class="pv-entity__date-range t-14 t-black--light t-normal"&gt;
        &lt;span class="visually-hidden"&gt;Dates d’emploi&lt;/span&gt;
        &lt;span&gt;juil. 2015 – juin 2019&lt;/span&gt;
      &lt;/h4&gt;
        &lt;h4 class="t-14 t-black--light t-normal"&gt;
          &lt;span class="visually-hidden"&gt;Durée d’emploi&lt;/span&gt;
          &lt;span class="pv-entity__bullet-item-v2"&gt;4 ans&lt;/span&gt;
        &lt;/h4&gt;
    &lt;/div&gt;
  
    &lt;h4 class="pv-entity__location t-14 t-black--light t-normal block"&gt;
      &lt;span class="visually-hidden"&gt;Lieu&lt;/span&gt;
      &lt;span&gt;Smarves&lt;/span&gt;
    &lt;/h4&gt;
  
  &lt;!----&gt;
  &lt;/div&gt;
  
  &lt;/a&gt;
          &lt;div id="ember261" class="pv-entity__extra-details t-14 t-black--light ember-view"&gt;&lt;p style="line-height:2rem;max-height:8rem;" id="ember262" class="pv-entity__description t-14 t-black t-normal inline-show-more-text inline-show-more-text--is-collapsed ember-view"&gt;It started as a 2 months internship in which my tasks were to:&lt;br&gt;• Analysed the company's profitability&lt;br&gt;•   Created the official corporate document on profitability&lt;br&gt;•   Designed and administered a corporate customer satisfaction survey&lt;br&gt;&lt;br&gt;Ever since, I am doing yearly financial and business analysis under my own business. It has been now 4 years that I am working with this company, with more and more responsibilities over the time such reporting and analysing the company's investing holdings' profitability.
  
      &lt;span class="inline-show-more-text__link-container-collapsed"&gt;
          &lt;span&gt;…&lt;/span&gt;
        &lt;button class="inline-show-more-text__button link" aria-expanded="false" data-ember-action="" data-ember-action-342="342"&gt;
          voir plus
        &lt;/button&gt;
      &lt;/span&gt;
  
  &lt;!----&gt;&lt;/p&gt;&lt;!----&gt;&lt;/div&gt;
      &lt;/div&gt;
  
        &lt;div class="pv-entity__actions"&gt;
  &lt;a data-control-name="edit_position" href="/in/gregoire-de-kermel/edit/position/708026390/" id="ember263" class="pv-profile-section__edit-action pv-profile-section__hoverable-action artdeco-button artdeco-button--tertiary artdeco-button--circle ember-view"&gt;          &lt;li-icon type="pencil-icon" role="img" aria-label="Modifier le poste Business Financial Analyst"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" data-supported-dps="24x24" fill="currentColor" width="24" height="24" focusable="false"&gt;
    &lt;path d="M21.71 5L19 2.29a1 1 0 00-.71-.29 1 1 0 00-.7.29L4 15.85 2 22l6.15-2L21.71 6.45a1 1 0 00.29-.74 1 1 0 00-.29-.71zM6.87 18.64l-1.5-1.5L15.92 6.57l1.5 1.5zM18.09 7.41l-1.5-1.5 1.67-1.67 1.5 1.5z"&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/li-icon&gt;
  &lt;/a&gt;&lt;!----&gt;      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;
  &lt;/li&gt;&lt;li id="ember265" class="pv-entity__position-group-pager pv-profile-section__list-item ember-view"&gt;        &lt;section id="813743952" class="pv-profile-section__card-item-v2 pv-profile-section pv-position-entity ember-view"&gt;  &lt;div class="display-flex justify-space-between full-width"&gt;
      &lt;div class="display-flex flex-column full-width"&gt;
  &lt;a data-control-name="background_details_company" href="/company/gsma/" id="ember268" class="full-width ember-view"&gt;          &lt;div class="pv-entity__logo company-logo"&gt;
    &lt;img src="https://media-exp1.licdn.com/dms/image/C560BAQGmHE5IziHPfw/company-logo_100_100/0?e=1593648000&amp;amp;v=beta&amp;amp;t=uonj7aae0F9Qr9Z7uDJAjX358njW5zCqaCrhF-m5wJU" loading="lazy" alt="GSMA" id="ember270" class="pv-entity__logo-img EntityPhoto-square-5 lazy-image loaded ember-view"&gt;
  &lt;/div&gt;
  &lt;div class="pv-entity__summary-info pv-entity__summary-info--background-section mb2"&gt;
    &lt;h3 class="t-16 t-black t-bold"&gt;Intern Analyst - Network 2020&lt;/h3&gt;
    &lt;p class="visually-hidden"&gt;Nom de l’entreprise&lt;/p&gt;
    &lt;p class="pv-entity__secondary-title t-14 t-black t-normal"&gt;
        GSMA
  &lt;!----&gt;  &lt;/p&gt;
      &lt;div class="display-flex"&gt;
      &lt;h4 class="pv-entity__date-range t-14 t-black--light t-normal"&gt;
        &lt;span class="visually-hidden"&gt;Dates d’emploi&lt;/span&gt;
        &lt;span&gt;mai 2016 – juil. 2016&lt;/span&gt;
      &lt;/h4&gt;
        &lt;h4 class="t-14 t-black--light t-normal"&gt;
          &lt;span class="visually-hidden"&gt;Durée d’emploi&lt;/span&gt;
          &lt;span class="pv-entity__bullet-item-v2"&gt;3 mois&lt;/span&gt;
        &lt;/h4&gt;
    &lt;/div&gt;
  
    &lt;h4 class="pv-entity__location t-14 t-black--light t-normal block"&gt;
      &lt;span class="visually-hidden"&gt;Lieu&lt;/span&gt;
      &lt;span&gt;London, Royaume-Uni&lt;/span&gt;
    &lt;/h4&gt;
  
  &lt;!----&gt;
  &lt;/div&gt;
  
  &lt;/a&gt;
          &lt;div id="ember272" class="pv-entity__extra-details t-14 t-black--light ember-view"&gt;&lt;p style="line-height:2rem;max-height:8rem;" id="ember273" class="pv-entity__description t-14 t-black t-normal inline-show-more-text inline-show-more-text--is-collapsed ember-view"&gt;Initially, I had the opportunity to use small and large data sets to reconcile, analyse and present to key stakeholders – developing strong excel capability in the process.&lt;br&gt;&lt;br&gt;Further developing these skills, I had the opportunity to deliver a project of work (end-to-end) from developing communications for data requests, clean data collection and storage processes and then developing a methodology for estimating market size metrics in a sustainable reporting process to the Network 2020 programme.&lt;br&gt;&lt;br&gt;Summary of milestones:&lt;br&gt;•    Reconciling, analysing and presenting information to key stakeholders&lt;br&gt;•  Request, store and model market estimations&lt;br&gt;•    Researching, collection and storing and communicating key business metrics
  
      &lt;span class="inline-show-more-text__link-container-collapsed"&gt;
          &lt;span&gt;…&lt;/span&gt;
        &lt;button class="inline-show-more-text__button link" aria-expanded="false" data-ember-action="" data-ember-action-343="343"&gt;
          voir plus
        &lt;/button&gt;
      &lt;/span&gt;
  
  &lt;!----&gt;&lt;/p&gt;&lt;!----&gt;&lt;/div&gt;
      &lt;/div&gt;
  
        &lt;div class="pv-entity__actions"&gt;
  &lt;a data-control-name="edit_position" href="/in/gregoire-de-kermel/edit/position/813743952/" id="ember274" class="pv-profile-section__edit-action pv-profile-section__hoverable-action artdeco-button artdeco-button--tertiary artdeco-button--circle ember-view"&gt;          &lt;li-icon type="pencil-icon" role="img" aria-label="Modifier le poste Intern Analyst - Network 2020"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" data-supported-dps="24x24" fill="currentColor" width="24" height="24" focusable="false"&gt;
    &lt;path d="M21.71 5L19 2.29a1 1 0 00-.71-.29 1 1 0 00-.7.29L4 15.85 2 22l6.15-2L21.71 6.45a1 1 0 00.29-.74 1 1 0 00-.29-.71zM6.87 18.64l-1.5-1.5L15.92 6.57l1.5 1.5zM18.09 7.41l-1.5-1.5 1.67-1.67 1.5 1.5z"&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/li-icon&gt;
  &lt;/a&gt;&lt;!----&gt;      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;
  &lt;/li&gt;  &lt;/ul&gt;
  
    &lt;div id="ember275" class="pv-experience-section__see-more pv-profile-section__actions-inline ember-view"&gt;&lt;button class="pv-profile-section__see-more-inline pv-profile-section__text-truncate-toggle link link-without-hover-state" aria-expanded="false"&gt;Afficher 1 expérience de plus
  &lt;li-icon aria-hidden="true" type="chevron-down-icon" class="pv-profile-section__toggle-detail-icon" size="small"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" data-supported-dps="16x16" fill="currentColor" width="16" height="16" focusable="false"&gt;
    &lt;path d="M8 9l5.93-4L15 6.54l-6.15 4.2a1.5 1.5 0 01-1.69 0L1 6.54 2.07 5z"&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/li-icon&gt;&lt;/button&gt;
  
  &lt;!----&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I've save the extract under an html file and opened it the following way: </p>
  
  <pre><code>def parse_html_file(filename):
      f = open(filename, encoding="utf8").read()
      parser = etree.HTMLParser()
      tree = etree.parse(StringIO(f), parser)
      return tree
  
  tree = parse_html_file('test.html')
  </code></pre>
  
  <p>I have 5 elements in my list <code>"pv-profile-section__section-info section-info pv-profile-section__section-info--has-more"</code>.</p>
  
  <p>The goal is to extract the job name, company name and contract type.</p>
  
  <p>So far, I've done the following:</p>
  
  <pre><code>job_location = tree.xpath(
      './/li[@class="pv-entity__position-group-pager pv-profile-section__list-item ember-view"]')
  
  di = {}
  
  for i in job_location:
      try:
          di['name'] = tree.xpath(
              '//h3[@class="t-16 t-black t-bold"]/text()')
      except:
          di['name'] = 'None'
      try:
          di['name'] = tree.xpath(
              '//h3[@class="t-16 t-black t-bold"]/text()')
      except:
          di['name'] = 'None'    
      try:
          di['contract'] = tree.xpath(
              '//span[@class="pv-entity__secondary-title separator"]/text()')
      except:
          di['contract'] = 'None'
  
  print(di)
  </code></pre>
  
  <p>It seems to be working but right now, the lenght of the "job" and "company" variables are both 5 while "contract_type" is 2.
  I would like to print something is there is no "contract_type" attribute inside the original loop like for the last element. When there is nothing, I'd like to display "None" for the contract_type.</p>
  
  <p>What I have so far:</p>
  
  <pre><code>{'name': ['Data Scientist', 'Data Scientist', 'Python &amp; React Native developer junior', 'Business Financial Analyst', 'Intern Analyst - Network 2020'], 'contract': ['Contrat en alternance', 'Contrat en alternance']}
  </code></pre>
  
  <p>What I'd like to get:</p>
  
  <p>{'name': ['Data Scientist', 'Data Scientist', 'Python &amp; React Native developer junior', 'Business Financial Analyst', 'Intern Analyst - Network 2020'], 'contract': ['Contrat en alternance', 'Contrat en alternance', '', '', '']}</p>
  
  <p>Do you guys could give me a hint on this task?</p>