In [1]:
import mechanize
import cookielib
# Browser
br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
# Browser options
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
# Want debugging messages?
#br.set_debug_http(True)
#br.set_debug_redirects(True)
#br.set_debug_responses(True)
# User-Agent (this is cheating, ok?)
br.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36')]
/home/zzz/anaconda2/lib/python2.7/site-packages/ipykernel/__main__.py:13: UserWarning: gzip transfer encoding is experimental!
In [2]:
#r = br.open('https://www.yelp.com/search?find_desc=vietnamese+food&find_loc=Hoboken&ns=1')
r = br.open('http://stackoverflow.com/search?q=how+to+find+duplicates+in+list+python')
html = r.read()
In [3]:
html
Out[3]:
'<!DOCTYPE html>\r\n<html>\r\n\r\n<head>\r\n\r\n<title>Posts containing 'how to find duplicates in list python' - Stack Overflow</title>\r\n <link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico?v=4f32ecc8f43d">\r\n <link rel="apple-touch-icon image_src" href="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">\r\n <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">\r\n <meta name="twitter:card" content="summary">\r\n <meta name="twitter:domain" content="stackoverflow.com"/>\r\n <meta property="og:type" content="website" />\r\n\r\n <meta property="og:image" itemprop="image primaryImageOfPage" content="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon@2.png?v=73d79a89bded" />\r\n <meta name="twitter:title" property="og:title" itemprop="title name" content="Posts containing 'how to find duplicates in list python'" />\r\n <meta name="twitter:description" property="og:description" itemprop="description" content="Q&A for professional and enthusiast programmers" />\r\n <meta property="og:url" content="http://stackoverflow.com/search?q=how+to+find+duplicates+in+list+python"/>\r\n\r\n \r\n \r\n <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>\r\n <script src="https://cdn.sstatic.net/Js/stub.en.js?v=8cbeac531f15"></script>\r\n <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/stackoverflow/all.css?v=9662112015d6">\r\n\r\n <link rel="alternate" type="application/atom+xml" title="Feed of recent questions" href="/feeds">\r\n <style>\r\n mark {\r\n background-color: transparent;\r\n color: inherit;\r\n }\r\n </style>\r\n <script>\r\n $(function () {\r\n // Not using is:visible checks in case people click multiple times\r\n var isToggled = false;\r\n\r\n $(\'.advanced-tips-toggle\').on("click", function() {\r\n if (!isToggled) {\r\n $(\'.advanced-tips\').slideDown(100, function () {\r\n $(\'.advanced-tips table\').fadeTo(200, 1);\r\n });\r\n } else {\r\n $(\'.advanced-tips table\').fadeTo(200, 0, function () {\r\n $(\'.advanced-tips\').slideUp(100);\r\n });\r\n }\r\n isToggled = !isToggled;\r\n return false;\r\n });\r\n });\r\n </script>\r\n\r\n\r\n <script>\r\n StackExchange.init({"locale":"en","stackAuthUrl":"https://stackauth.com","networkMetaHostname":"meta.stackexchange.com","serverTime":1488485937,"routeName":"Search/Search","site":{"name":"Stack Overflow","description":"Q&A for professional and enthusiast programmers","isNoticesTabEnabled":true,"recaptchaPublicKey":"6LdchgIAAAAAAJwGpIzRQSOFaO0pU6s44Xt8aTwc","recaptchaAudioLang":"en","enableNewTagCreationWarning":true,"insertSpaceAfterNameTabCompletion":false,"id":1,"enableInsertDocLinkDialog":true,"enableSocialMediaInSharePopup":true},"timingsGuid":"db5a7436-684e-4e1e-8b51-e6e27bc71d6b","timingsInfo":"RbJs/RIIT7uP+t4Yisf/uY9I5qePLdWKlvd7aFYwVeYWNhtOp0XZY2voyKg65pXcZjYRx0w2Xo3F3Ma1VTIVJ5PB1zjYahXbKvKtezaXg4qqeCUp0GHOYAAB5IBtxIu9ariGKdp6z3zhKWy8Gq32pp6zc2bvV5EvIFZljLiFu8ml2LeI42JUGJAG8g/3YQM0TU+4GKTOpndyI94jadgCOPX9ki66Xakk51udUGq2TkYb3Dj/mtEes2m9KEhrfjMY","user":{"fkey":"9bbe230d042cc118f2889a9c950ec03d","rep":0,"isAnonymous":true,"isAnonymousNetworkWide":true,"canSeeNewHeaderDesign":true,"ab":{"question_show_tweaks":{"v":"altern_unansw_cta","g":2}}},"events":{"postType":{"question":1},"postEditionSection":{"title":1,"body":2,"tags":3}},"story":{"minCompleteBodyLength":75}}, {"site":{"allowImageUploads":true,"enableUserHovercards":true,"styleCode":true,"enableNewLinkInsertDialog":true,"enableImgurHttps":true,"forceHttpsImages":true},"comments":{},"userProfile":{"openGraphAPIKey":"58740831ad23540e00c58987"},"tags":{},"accounts":{"currentPasswordRequiredForChangingStackIdPassword":true},"flags":{"allowRetractingFlags":true},"analytics":{"clientTimingsAbsoluteTimeout":30000,"clientTimingsDebounceTimeout":1000},"snippets":{"snippetsEnabled":true,"renderDomain":"stacksnippets.net"},"markdown":{"asteriskIntraWordEmphasis":true}});\r\n StackExchange.using.setCacheBreakers({"js/prettify-full.en.js":"2555d7dfec86","js/moderator.en.js":"6ac1015d4659","js/full-anon.en.js":"3bcbf05d0749","js/full.en.js":"99175fb403f9","js/wmd.en.js":"22e4f38e2016","js/third-party/jquery.autocomplete.min.js":"d3b8fa7fdf74","js/third-party/jquery.autocomplete.min.en.js":"","js/mobile.en.js":"617589bf91c4","js/help.en.js":"a56fdf9b9ff2","js/tageditor.en.js":"248fce004255","js/tageditornew.en.js":"58f9c49bd07f","js/inline-tag-editing.en.js":"2ddfa79492e7","js/revisions.en.js":"4ba8f70874c4","js/review.en.js":"88027ca044f4","js/tagsuggestions.en.js":"ddb0e41afe26","js/post-validation.en.js":"2d1f822fece2","js/explore-qlist.en.js":"d33e3ab2f2e0","js/events.en.js":"d3f20a37a0d6","js/keyboard-shortcuts.en.js":"7473f1cb9735","js/external-editor.en.js":"dec8b7cab79e","js/adops.en.js":"9a6a7812a212","js/external-editor.en.js":"dec8b7cab79e","js/snippet-javascript.en.js":"e76aab1cc9bc","js/snippet-javascript-codemirror.en.js":"b339600799cf"});\r\n StackExchange.using("gps", function() {\r\n StackExchange.gps.init(true);\r\n });\r\n </script>\r\n \r\n <script>\r\n StackExchange.ready(function () {\r\n $(\'#nav-tour\').click(function () {\r\n StackExchange.using("gps", function() {\r\n StackExchange.gps.track("aboutpage.click", { aboutclick_location: "headermain" }, true);\r\n });\r\n });\r\n });\r\n </script>\r\n</head>\r\n<body class="search-page new-topbar">\r\n <noscript><div id="noscript-padding"></div></noscript>\r\n <script>(function () { var old = $.fn.contents; $.fn.contents = function () { try { return old.apply(this, arguments); } catch (e) { return $([]); } } })()</script>\r\n <iframe id="adzerk-user-match" width="0" height="0" frameborder="0" scrolling="no" onload="window.AUMIframeDone=true"\r\n src="https://ssum-sec.casalemedia.com/usermatch?s=183712&cb=https%3A%2F%2Fengine.adzerk.net%2Fudb%2F22%2Fsync%2Fi.gif%3FpartnerId%3D1%26userId%3D"\r\n style="display: none;" marginheight="0" marginwidth="0"></iframe>\r\n\r\n <div id="notify-container"></div>\r\n <div id="custom-header"></div>\r\n\n\n<header class="so-header js-so-header _fixed">\n <div class="-container">\n <div class="-main"> \n <a href="http://stackoverflow.com" class="-logo ">\n <span class="-img">Stack Overflow</span>\n </a>\n\n <nav class="navigation">\n <ol class="-list">\n <li class="-item">\n <a id="nav-questions" href="/questions" class="-link js-gps-track" \n data-gps-track="top_nav.click({is_current:false, location:26, destination:1})">Questions</a>\n </li>\n\n <li class="-item">\n <a id="nav-jobs" href="/jobs?med=site-ui&ref=jobs-tab" class="-link js-gps-track" \n data-gps-track="top_nav.click({is_current:false, location:26, destination:6})">Jobs</a>\n </li>\n <li class="-item">\n <a id="nav-docs" href="/documentation" class="-link js-gps-track" \n data-gps-track="top_nav.click({is_current:false, location:26, destination:7})">Documentation <small class=\'beta-badge\'>beta</small></a>\n </li>\n <li class="-item">\n <a id="nav-tags" href="/tags" class="-link js-gps-track" \n data-gps-track="top_nav.click({is_current:false, location:26, destination:2})">Tags</a>\n </li>\n\n <li class="-item">\n <a id="nav-users" href="/users" class="-link js-gps-track" \n data-gps-track="top_nav.click({is_current:false, location:26, destination:3})">Users</a>\n </li>\n\n </ol>\n </nav>\n\n <form id="search" action="/search" method="get" class="searchbar" autocomplete="off">\n <svg viewBox="0 0 18 18" width="18" height="18" role="icon"><path fill-rule="evenodd" d="M12.864 11.32h-.813l-.288-.277A6.66 6.66 0 0 0 13.38 6.69a6.69 6.69 0 1 0-6.69 6.69 6.66 6.66 0 0 0 4.354-1.617l.278.288v.813L16.467 18 18 16.467l-5.136-5.146zm-6.174 0a4.625 4.625 0 0 1-4.632-4.63A4.625 4.625 0 0 1 6.69 2.058a4.625 4.625 0 0 1 4.63 4.632 4.625 4.625 0 0 1-4.63 4.63z"/></svg>\n <input name="q" type="text" placeholder="Search..." value="how to find duplicates in list python" tabindex="1" autocomplete="off" maxlength="240" class="f-input js-search-field" />\n <button type="submit" class="btn js-search-submit">\n <svg viewBox="0 0 18 18" width="18" height="18" role="icon"><path fill-rule="evenodd" d="M12.864 11.32h-.813l-.288-.277A6.66 6.66 0 0 0 13.38 6.69a6.69 6.69 0 1 0-6.69 6.69 6.66 6.66 0 0 0 4.354-1.617l.278.288v.813L16.467 18 18 16.467l-5.136-5.146zm-6.174 0a4.625 4.625 0 0 1-4.632-4.63A4.625 4.625 0 0 1 6.69 2.058a4.625 4.625 0 0 1 4.63 4.632 4.625 4.625 0 0 1-4.63 4.63z"/></svg>\n </button>\n </form>\n\n </div>\n \n\n\n<div class="-actions">\n <nav class="secondary-nav">\n <div class="-dialog-container js-topbar-dialog-corral">\n\r\n\r\n <div class="topbar-dialog siteSwitcher-dialog dno">\r\n <div class="header">\r\n <h3><a href="//stackoverflow.com">current community</a>\r\n </h3>\r\n </div>\r\n <div class="modal-content current-site-container">\r\n <ul class="current-site">\r\n <li>\r\n <div class="related-links">\r\n <a href="http://chat.stackoverflow.com" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })"\r\n>chat</a>\r\n </div>\r\n\r\n <a href="//stackoverflow.com"\r\n class="current-site-link site-link js-gps-track"\r\n data-id="1"\r\n data-gps-track="site_switcher.click({ item_type:3 })">\r\n <div class="site-icon favicon favicon-stackoverflow" title="Stack Overflow"></div>\r\n Stack Overflow\r\n </a>\r\n\r\n </li>\r\n <li class="related-site">\r\n <div class="L-shaped-icon-container">\r\n <span class="L-shaped-icon"></span>\r\n </div>\r\n\r\n \r\n <a href="http://meta.stackoverflow.com"\r\n class="site-link js-gps-track"\r\n data-id="552"\r\n data-gps-track="site.switch({ target_site:552, item_type:3 }),site_switcher.click({ item_type:4 })">\r\n <div class="site-icon favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div>\r\n Meta Stack Overflow\r\n </a>\r\n\r\n </li>\r\n </ul>\r\n </div>\r\n\r\n <div class="header" id="your-communities-header">\r\n <h3>\r\nyour communities </h3>\r\n\r\n </div>\r\n <div class="modal-content" id="your-communities-section">\r\n\r\n <div class="call-to-login">\r\n<a href="https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=%2fusers%2fstory%2fcurrent&amp;utm_source=stackoverflow.com&amp;utm_medium=dev-story&amp;utm_campaign=signup-redirect" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:10 })"\r\n>Sign up</a> or <a href="https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=http%3a%2f%2fstackoverflow.com%2fsearch%3fq%3dhow%2bto%2bfind%2bduplicates%2bin%2blist%2bpython" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:11 })"\r\n>log in</a> to customize your list.\r\n </div>\r\n </div>\r\n\r\n <div class="header">\r\n <h3><a href="//stackexchange.com/sites">more stack exchange communities</a>\r\n </h3>\r\n <a href="http://stackoverflow.blog" class="fr">company blog</a>\r\n </div>\r\n <div class="modal-content">\r\n <div class="child-content"></div>\r\n </div> \r\n </div>\r\n <div class="topbar-dialog help-dialog js-help-dialog dno">\n <div class="modal-content">\n <ul>\n <li>\n <a href="/tour" class="js-gps-track" data-gps-track="help_popup.click({ item_type:1 })">\n Tour\n <span class="item-summary">\n Start here for a quick overview of the site\n </span>\n </a>\n </li>\n <li>\n <a href="/help" class="js-gps-track" data-gps-track="help_popup.click({ item_type:4 })">\n Help Center\n <span class="item-summary">\n Detailed answers to any questions you might have\n </span>\n </a>\n </li>\n <li>\n <a href="//meta.stackoverflow.com" class="js-gps-track" data-gps-track="help_popup.click({ item_type:2 })">\n Meta\n <span class="item-summary">\n Discuss the workings and policies of this site\n </span>\n </a>\n </li>\n <li>\n <a href="http://stackoverflow.com/company/about" class="js-gps-track" data-gps-track="help_popup.click({ item_type:6 })">\n About Us\n <span class="item-summary">\n Learn more about Stack Overflow the company\n </span>\n </a>\n </li>\n <li>\n <a href="https://www.stackoverflowbusiness.com/?ref=topbar_help" class="js-gps-track" data-gps-track="help_popup.click({ item_type:7 })">\n Business\n <span class="item-summary">\n Learn more about hiring developers or posting ads with us\n </span>\n </a>\n </li>\n </ul>\n </div>\n </div>\n\n </div>\n <ol class="-list">\n \n <li class="-item"><a href="#" class="-link js-help-button" title="Help Center and other resources">\n <svg viewBox="0 0 18 18" width="18" height="18" role="icon"><path fill-rule="evenodd" d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm.812 13.126c-.02.716-.55 1.157-1.238 1.137-.659-.02-1.177-.49-1.157-1.209.02-.715.566-1.17 1.225-1.15.691.021 1.194.507 1.17 1.222zm1.956-5.114c-.168.237-.546.542-1.02.912l-.527.361c-.257.197-.417.43-.502.695-.044.141-.076.507-.084.752-.004.048-.032.156-.181.156H7.883c-.165 0-.185-.096-.18-.144.023-.667.12-1.218.397-1.66.374-.594 1.426-1.221 1.426-1.221.161-.12.286-.25.382-.39.177-.24.321-.51.321-.8 0-.333-.08-.65-.293-.915-.249-.31-.518-.458-1.036-.458-.51 0-.808.257-1.021.594-.213.338-.177.735-.177 1.097H5.746c0-1.366.357-2.238 1.112-2.752.51-.35 1.162-.502 1.921-.502.996 0 1.788.184 2.487.715.647.49.988 1.181.988 2.113 0 .575-.2 1.057-.486 1.447z" /></svg>\n </a></li>\n <li class="-item">\n <a href="//stackexchange.com" class="-link js-site-switcher-button js-gps-track" data-gps-track="site_switcher.show" title="A list of all 166 Stack Exchange sites">\n <svg viewBox="0 0 18 19" width="18" height="19" role="icon"><path fill-rule="evenodd" d="M0 14a2 2 0 0 0 2 2h10v3l3-3h1a2 2 0 0 0 2-2v-2H0v2zM16 0H2a2 2 0 0 0-2 2v2h18V2a2 2 0 0 0-2-2zM0 6h18v4H0V6z" /></svg>\n </a>\n </li>\n\n\n </ol>\n </nav>\n <div class="-ctas">\n <a href="https://stackoverflow.com/users/login?ssrc=head&returnurl=http%3a%2f%2fstackoverflow.com%2fsearch%3fq%3dhow%2bto%2bfind%2bduplicates%2bin%2blist%2bpython" class="login-link btn-clear" rel="nofollow">Log In</a>\n <a href="https://stackoverflow.com/users/signup?ssrc=head&returnurl=%2fusers%2fstory%2fcurrent&utm_source=stackoverflow.com&utm_medium=dev-story&utm_campaign=signup-redirect" class="login-link btn" rel="nofollow">Sign Up</a>\n\n </div>\n</div>\n </div>\n</header>\n\n <script>\n StackExchange.ready(function () { StackExchange.topbar.init(); });\n StackExchange.scrollPadding.setPaddingTop(60, 10); </script>\n\r\n <div class="container">\r\n \r\n\r\n\r\n <div id="content" class="snippet-hidden">\r\n\r\n\r\n\r\n \xef\xbb\xbf\r\n<div id="mainbar">\r\n <div class="subheader search-header">\r\n <h1>Search</h1>\r\n </div>\r\n <form id="bigsearch" action="/search" method="get">\r\n <table>\r\n <tr>\r\n <td class="col1"><input name="q" class="textbox" type="text" maxlength="140" size="80" value="how to find duplicates in list python"></td>\r\n <td class="col2"><input type="submit" value="search"/></td>\r\n </tr>\r\n </table>\r\n </form>\r\n\r\n <div class="subheader results-header">\r\n <h2>\r\n 158 <span class="results-label">results</span>\r\n </h2>\r\n <div id="tabs">\r\n <a class="youarehere" href="/search?tab=relevance&q=how%20to%20find%20duplicates%20in%20list%20python" data-nav-xhref="" title="Search results with best match to search terms" data-value="relevance" data-shortcut="">\r\n relevance</a>\r\n <a href="/search?tab=newest&q=how%20to%20find%20duplicates%20in%20list%20python" data-nav-xhref="" title="Newest search results" data-value="newest" data-shortcut="">\r\n newest</a>\r\n <a href="/search?tab=votes&q=how%20to%20find%20duplicates%20in%20list%20python" data-nav-xhref="" title="Highest voted search results" data-value="votes" data-shortcut="">\r\n votes</a>\r\n <a href="/search?tab=active&q=how%20to%20find%20duplicates%20in%20list%20python" data-nav-xhref="" title="Recently active search results" data-value="active" data-shortcut="">\r\n active</a>\r\n</div>\r\n </div>\r\n <div class="search-results js-search-results">\r\n\r\n <div class="question-summary search-result" id="question-summary-26189496" data-position="1">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>1</strong></span>\r\n <div class="viewcount">vote</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>2</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/26189496/how-to-find-duplicates-values-in-list-python" data-searchsession="/questions/26189496/how-to-find-duplicates-values-in-list-python?s=1|1.5947" title="How to find duplicates values in list Python">\r\n Q: How to find duplicates values in list Python \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n I was wondering <span class="result-highlight">how</span> can I know if when a user inputs a value, that value already exists in a <span class="result-highlight">list</span>.\n\nFor example;\n\nlis = ['foo', 'boo', 'hoo']\n\n\nuser inputs:\n\n'boo'\n\n\nNow my question is <span class="result-highlight">how</span> can I tell the user this value already exists inside the <span class="result-highlight">list</span>.\n … \r\n </div>\r\n <div class="tags user-tags t-python t-list t-duplicates">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/list" class="post-tag" title="show questions tagged 'list'" rel="tag">list</a> <a href="/questions/tagged/duplicates" class="post-tag" title="show questions tagged 'duplicates'" rel="tag">duplicates</a> </div>\r\n <div class="started fr">\r\nasked <span title="2014-10-04 04:05:57Z" class="relativetime">Oct 4 \'14</span> by <a href="/users/3973873/andre">Andre</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-20881716" data-position="2">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>-6</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>2</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/20881716/python-algorithm-find-duplicates-in-list" data-searchsession="/questions/20881716/python-algorithm-find-duplicates-in-list?s=2|1.1658" title="python algorithm, find duplicates in list">\r\n Q: python algorithm, find duplicates in list [closed]\r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n I need to <span class="result-highlight">find</span> all unique values in <span class="result-highlight">python</span> <span class="result-highlight">list</span>, and if there was a <span class="result-highlight">duplicate</span> write <span class="result-highlight">how</span> many of them, example:\n\n['apple','cherry','coffee','apple','coffee','coffee']\n\n\nand the output should be: \n\napple 2\ncherry 1\ncoffee 3\n\n … \r\n </div>\r\n <div class="tags user-tags t-python t-algorithm">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/algorithm" class="post-tag" title="show questions tagged 'algorithm'" rel="tag">algorithm</a> </div>\r\n <div class="started fr">\r\nasked <span title="2014-01-02 11:16:29Z" class="relativetime">Jan 2 \'14</span> by <a href="/users/3057314/user3057314">user3057314</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-41576429" data-position="3">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>0</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>2</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/41576429/python-how-to-find-and-merge-duplicates-in-list-of-addresses-which-are-lists" data-searchsession="/questions/41576429/python-how-to-find-and-merge-duplicates-in-list-of-addresses-which-are-lists?s=3|1.1459" title="Python - How to find and merge duplicates in list of addresses (which are lists themselves)">\r\n Q: Python - How to find and merge duplicates in list of addresses (which are lists themselves) \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n I have a <span class="result-highlight">list</span> of addresses that I scraped from a site and I would like to compare that to a <span class="result-highlight">list</span> of addresses from a previous scrape to merge and remove the <span class="result-highlight">duplicates</span>. The <span class="result-highlight">list</span> I scraped has zip … codes and sometimes cities while the previous scraped <span class="result-highlight">list</span> only has cities, no zip. My end goal is to merge all the <span class="result-highlight">duplicates</span> and leave entries without <span class="result-highlight">duplicates</span>.\n\nHere is an example of 2 entries … \r\n </div>\r\n <div class="tags user-tags t-python t-list t-merge t-duplicates">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/list" class="post-tag" title="show questions tagged 'list'" rel="tag">list</a> <a href="/questions/tagged/merge" class="post-tag" title="show questions tagged 'merge'" rel="tag">merge</a> <a href="/questions/tagged/duplicates" class="post-tag" title="show questions tagged 'duplicates'" rel="tag">duplicates</a> </div>\r\n <div class="started fr">\r\nasked <span title="2017-01-10 19:03:10Z" class="relativetime">Jan 10</span> by <a href="/users/7400981/tykom">tykom</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-21925497" data-position="4">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>3</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>7</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/21925497/how-to-find-a-duplicate-in-a-list-without-using-set-in-python" data-searchsession="/questions/21925497/how-to-find-a-duplicate-in-a-list-without-using-set-in-python?s=4|1.0777" title="How to find a duplicate in a list without using set in python?">\r\n Q: How to find a duplicate in a list without using set in python? \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n I know that we can use the set in <span class="result-highlight">python</span> to <span class="result-highlight">find</span> if there is any <span class="result-highlight">duplicate</span> in a <span class="result-highlight">list</span>. I was just wondering, if we can <span class="result-highlight">find</span> a <span class="result-highlight">duplicate</span> in a <span class="result-highlight">list</span> without using set.\n\nSay, my <span class="result-highlight">list</span> is \n\na=['1545','1254','1545']\n\n\nthen <span class="result-highlight">how</span> to <span class="result-highlight">find</span> a <span class="result-highlight">duplicate</span>?\n … \r\n </div>\r\n <div class="tags user-tags t-python">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> </div>\r\n <div class="started fr">\r\nasked <span title="2014-02-21 04:47:18Z" class="relativetime">Feb 21 \'14</span> by user3260982 </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-31047647" data-position="5">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>3</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>3</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/31047647/how-to-find-duplicates-in-a-python-list-that-are-adjacent-to-each-other-and-list" data-searchsession="/questions/31047647/how-to-find-duplicates-in-a-python-list-that-are-adjacent-to-each-other-and-list?s=5|1.0348" title="How to find duplicates in a python list that are adjacent to each other and list them with respect to their indices?">\r\n Q: How to find duplicates in a python list that are adjacent to each other and list them with r… \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n and <span class="result-highlight">list</span> <span class="result-highlight">duplicates</span> in <span class="result-highlight">Python</span> <span class="result-highlight">list</span>\n\nIdentify <span class="result-highlight">duplicate</span> values in a <span class="result-highlight">list</span> in <span class="result-highlight">Python</span>\n\nThis is where I am right now:\n\nr = csv.reader(data, delimiter= '\\t')\ncolumns = []\nfor row in r:\n # adds column … I have a program that reads a .csv file, checks for any mismatch in column length (by comparing it to the header-fields), which then returns everything it found out as a <span class="result-highlight">list</span> (and then writes … \r\n </div>\r\n <div class="tags user-tags t-python t-list t-csv t-dictionary t-duplicates">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/list" class="post-tag" title="show questions tagged 'list'" rel="tag">list</a> <a href="/questions/tagged/csv" class="post-tag" title="show questions tagged 'csv'" rel="tag">csv</a> <a href="/questions/tagged/dictionary" class="post-tag" title="show questions tagged 'dictionary'" rel="tag">dictionary</a> <a href="/questions/tagged/duplicates" class="post-tag" title="show questions tagged 'duplicates'" rel="tag">duplicates</a> </div>\r\n <div class="started fr">\r\nasked <span title="2015-06-25 10:23:14Z" class="relativetime">Jun 25 \'15</span> by <a href="/users/3460139/christian-w">Christian W.</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-22923084" data-position="6">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>1</strong></span>\r\n <div class="viewcount">vote</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>3</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/22923084/how-to-find-out-if-there-are-any-duplicates-in-list-of-lists" data-searchsession="/questions/22923084/how-to-find-out-if-there-are-any-duplicates-in-list-of-lists?s=6|0.9202" title="How to find out if there are any duplicates in list of lists">\r\n Q: How to find out if there are any duplicates in list of lists \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n lists in <span class="result-highlight">python</span> and return matches and <span class="result-highlight">How</span> to <span class="result-highlight">find</span> common elements in <span class="result-highlight">list</span> of lists?\n\nHowever, they're not quite what I'm looking for. Say for example I have this <span class="result-highlight">list</span> of lists:\n\nlist_x = [[66,76 … So I'm taking an intro computer science course right now, and I was wondering <span class="result-highlight">how</span> to check if there were any <span class="result-highlight">duplicates</span> within multiple lists. I've read up on these answers:\n\n<span class="result-highlight">How</span> can I compare two … \r\n </div>\r\n <div class="tags user-tags t-python t-list t-python-3ûx t-duplicates">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/list" class="post-tag" title="show questions tagged 'list'" rel="tag">list</a> <a href="/questions/tagged/python-3.x" class="post-tag" title="show questions tagged 'python-3.x'" rel="tag">python-3.x</a> <a href="/questions/tagged/duplicates" class="post-tag" title="show questions tagged 'duplicates'" rel="tag">duplicates</a> </div>\r\n <div class="started fr">\r\nasked <span title="2014-04-07 21:04:41Z" class="relativetime">Apr 7 \'14</span> by <a href="/users/3440123/user3440123">user3440123</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-33335058" data-position="7">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>0</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>2</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/33335058/how-to-find-a-duplicate-in-a-list-without-in-built-functions-in-python" data-searchsession="/questions/33335058/how-to-find-a-duplicate-in-a-list-without-in-built-functions-in-python?s=7|0.9078" title="How to find a duplicate in a list without in-built functions in Python?">\r\n Q: How to find a duplicate in a list without in-built functions in Python? \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n I'm trying to <span class="result-highlight">find</span> if there is a <span class="result-highlight">duplicate</span> within a <span class="result-highlight">list</span> without using the in-built functions. So far I have something like this however it does not seem to be working. Can anyone help? Give pointers … ? Improvements? I'd appreciate it. (<span class="result-highlight">Python</span> version 2.7.10)\n\ndef DupSearch(<span class="result-highlight">list</span>):\ncounter=0\nfor i in range(len(<span class="result-highlight">list</span>)):\n if <span class="result-highlight">list</span>[i]==<span class="result-highlight">list</span>[0]:\n for j in range(len(<span class="result-highlight">list</span>)):\n if <span class="result-highlight">list</span>[j … \r\n </div>\r\n <div class="tags user-tags t-python t-duplicates">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/duplicates" class="post-tag" title="show questions tagged 'duplicates'" rel="tag">duplicates</a> </div>\r\n <div class="started fr">\r\nasked <span title="2015-10-25 21:03:38Z" class="relativetime">Oct 25 \'15</span> by <a href="/users/5463291/sectah">Sectah</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-17202444" data-position="8">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>-1</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered">\r\n <strong>3</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/17202444/python-how-to-find-duplicates-in-a-list-and-update-these-duplicate-items-by-re" data-searchsession="/questions/17202444/python-how-to-find-duplicates-in-a-list-and-update-these-duplicate-items-by-re?s=8|0.8365" title="Python : How to find duplicates in a list and update these duplicate items by renaming them with a progressive letter added">\r\n Q: Python : How to find duplicates in a list and update these duplicate items by renaming them … \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n I have a <span class="result-highlight">list</span> of items like this:\n\n['T1','T2','T2','T2','T2','T3','T3' ]\n\nI need to make sure that <span class="result-highlight">duplicates</span> are renamed with a progressive letter added like this:\n\n['T1','T2A','T2B','T2C','T2D … ','T3A','T3B']\n\nbut only if there is more than 1 occurrence of the same item.\n\nAlso, is it possible to do so without generating a new <span class="result-highlight">list</span>?\n\nAny ideas?\n … \r\n </div>\r\n <div class="tags user-tags t-python t-list t-duplicates t-rename">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/list" class="post-tag" title="show questions tagged 'list'" rel="tag">list</a> <a href="/questions/tagged/duplicates" class="post-tag" title="show questions tagged 'duplicates'" rel="tag">duplicates</a> <a href="/questions/tagged/rename" class="post-tag" title="show questions tagged 'rename'" rel="tag">rename</a> </div>\r\n <div class="started fr">\r\nasked <span title="2013-06-19 22:27:34Z" class="relativetime">Jun 19 \'13</span> by <a href="/users/2503109/ariel-salvo-caliban">Ariel Salvo Caliban</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-29733813" data-position="9">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>3</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>4</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/29733813/python-optimize-how-to-find-duplicate-value-and-value-index-in-a-list" data-searchsession="/questions/29733813/python-optimize-how-to-find-duplicate-value-and-value-index-in-a-list?s=9|0.7297" title="Python optimize how to find duplicate value and value index in a list">\r\n Q: Python optimize how to find duplicate value and value index in a list \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n I have a <span class="result-highlight">list</span> with 18 000 unique ID.\nID are the concatenation of letters A, B, C, D.\nI have made a code who group ID by ID[0:-1] and give index position of the <span class="result-highlight">duplicate</span> ID.\n\nThat's works well … ']\n\nstartTime = time.time()\nb = [i[0:-1] for i in a]\nb = <span class="result-highlight">list</span>(set(b))\n\n\nresult = range(len(b))\nit = 0\nfor i in result:\n result[i] = [b[i], []]\n for j in xrange(len(a)):\n if b[i] == a[j][0:-1 … \r\n </div>\r\n <div class="tags user-tags t-python t-performance t-list t-optimization t-duplicates">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/performance" class="post-tag" title="show questions tagged 'performance'" rel="tag">performance</a> <a href="/questions/tagged/list" class="post-tag" title="show questions tagged 'list'" rel="tag">list</a> <a href="/questions/tagged/optimization" class="post-tag" title="show questions tagged 'optimization'" rel="tag">optimization</a> <a href="/questions/tagged/duplicates" class="post-tag" title="show questions tagged 'duplicates'" rel="tag">duplicates</a> </div>\r\n <div class="started fr">\r\nasked <span title="2015-04-19 18:11:28Z" class="relativetime">Apr 19 \'15</span> by <a href="/users/1743230/guilhain">Guilhain</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-41862084" data-position="10">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>-4</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered">\r\n <strong>1</strong>answer\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/41862084/replacing-one-specific-duplicate-in-list-of-duplicates-in-python" data-searchsession="/questions/41862084/replacing-one-specific-duplicate-in-list-of-duplicates-in-python?s=10|0.5823" title="Replacing ONE specific duplicate in list of duplicates in python">\r\n Q: Replacing ONE specific duplicate in list of duplicates in python \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n () method and referring to the specific <span class="result-highlight">duplicate</span> with its index, but that changes all of the <span class="result-highlight">duplicates</span>. What should I do? This is my first major project in <span class="result-highlight">python</span>, so I'm a beginner.\n … I have a <span class="result-highlight">list</span> of lists of words, some of which are <span class="result-highlight">duplicates</span>.\n\nL = [['I'], ['like'], ['candy'], ['end'], ['do'], ['you'], ['end'], ['okay'], ['end']]\n\n\nWhat I am trying to do is to shorten the <span class="result-highlight">list</span> … \r\n </div>\r\n <div class="tags user-tags t-python t-list t-duplicates">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/list" class="post-tag" title="show questions tagged 'list'" rel="tag">list</a> <a href="/questions/tagged/duplicates" class="post-tag" title="show questions tagged 'duplicates'" rel="tag">duplicates</a> </div>\r\n <div class="started fr">\r\nasked <span title="2017-01-25 21:35:49Z" class="relativetime">Jan 25</span> by <a href="/users/7421875/saturnus">saturnus</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-4095523" data-position="11">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>8</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered">\r\n <strong>4</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/4095523/script-to-find-duplicates-in-a-csv-file" data-searchsession="/questions/4095523/script-to-find-duplicates-in-a-csv-file?s=11|0.5205" title="Script to find duplicates in a csv file">\r\n Q: Script to find duplicates in a csv file \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n I have a 40 MB csv file with 50,000 records. Its a giant product listing. Each row has close to 20 fields. [Item#, UPC, Desc, etc]\n\n<span class="result-highlight">How</span> can I,\n\na) <span class="result-highlight">Find</span> and Print <span class="result-highlight">duplicate</span> rows. [This file is a large … appended file, so I have multiple headers included in the file which I need to remove, so I wanted to know exact rows which are <span class="result-highlight">duplicate</span> first.]\n\nb) <span class="result-highlight">Find</span> and Print <span class="result-highlight">duplicate</span> rows based on a column … \r\n </div>\r\n <div class="tags user-tags t-bash t-python t-perl">\r\n<a href="/questions/tagged/bash" class="post-tag" title="show questions tagged 'bash'" rel="tag">bash</a> <a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/perl" class="post-tag" title="show questions tagged 'perl'" rel="tag">perl</a> </div>\r\n <div class="started fr">\r\nasked <span title="2010-11-04 03:29:13Z" class="relativetime">Nov 4 \'10</span> by bcrawl </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-39229769" data-position="12">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>-1</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>2</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/39229769/how-to-find-length-of-the-sequence-in-a-list-using-python-with-duplicates" data-searchsession="/questions/39229769/how-to-find-length-of-the-sequence-in-a-list-using-python-with-duplicates?s=12|0.4968" title="How to find length of the sequence in a list using python [with Duplicates]?">\r\n Q: How to find length of the sequence in a list using python [with Duplicates]? [duplicate]\r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n I am trying with below code. \n\nfrom itertools import groupby\n\nrange_mod = ['P', 'P', 'P', 'P', 'N', 'N', 'N', 'N', 'P', 'P', 'P']\n\nprint(dict((i,len(<span class="result-highlight">list</span>(j))) for i, j in groupby(range_mod)))\n\n\nNote … : Output need not be in Dict\n\nActual Output:\n\n{'P': 3, 'N': 4}\n\n\nExpected output: I am aware Dictionary doesn't allow <span class="result-highlight">duplicate</span> keys. So looking for other options\n\n{'P': 4, 'N': 4, 'P' : 3}\n\n\nThanks in advance.\n … \r\n </div>\r\n <div class="tags user-tags t-python">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> </div>\r\n <div class="started fr">\r\nasked <span title="2016-08-30 14:07:38Z" class="relativetime">Aug 30 \'16</span> by <a href="/users/2799214/gokulkrishna-surapureddy">Gokulkrishna Surapureddy</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-1920145" data-position="13">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>19</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered">\r\n <strong>14</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/1920145/how-to-find-duplicate-elements-in-array-using-for-loop-in-python" data-searchsession="/questions/1920145/how-to-find-duplicate-elements-in-array-using-for-loop-in-python?s=13|0.4869" title="How to find duplicate elements in array using for loop in Python?">\r\n Q: How to find duplicate elements in array using for loop in Python? \r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n code to <span class="result-highlight">find</span> the <span class="result-highlight">duplicate</span> elements in the list_a. I don't want to remove the elements from <span class="result-highlight">list</span>.\n\nBut I want to use for loop here.\nNormally C/C++ we use like this I guess:\n\n for (int i=0;i … I have a <span class="result-highlight">list</span> with <span class="result-highlight">duplicate</span> elements:\n\n list_a=[1,2,3,5,6,7,5,2]\n\n tmp=[]\n\n for i in list_a:\n if tmp.__contains__(i):\n print i\n else:\n tmp.append(i)\n\n\nI have used the above … \r\n </div>\r\n <div class="tags user-tags t-python t-duplicates">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/duplicates" class="post-tag" title="show questions tagged 'duplicates'" rel="tag">duplicates</a> </div>\r\n <div class="started fr">\r\nasked <span title="2009-12-17 08:01:33Z" class="relativetime">Dec 17 \'09</span> by <a href="/users/190350/beginner">Beginner</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-11615041" data-position="14">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>5</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>4</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/11615041/how-to-find-match-items-from-two-lists" data-searchsession="/questions/11615041/how-to-find-match-items-from-two-lists?s=14|0.4110" title="How to find match items from two lists?">\r\n Q: How to find match items from two lists? [duplicate]\r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n \n Possible <span class="result-highlight">Duplicate</span>:\n <span class="result-highlight">Python</span>: <span class="result-highlight">How</span> to <span class="result-highlight">find</span> <span class="result-highlight">list</span> intersection? \n\n\n\n\nI have two lists of data in a .txt\n\ndata1 = "name1", "name2", "name3", "name4" etc.\n\ndata2 = "name3", "name6", "name10" etc.\n\n\nI want to <span class="result-highlight">find</span> out which names appears in both <span class="result-highlight">list</span>\n<span class="result-highlight">How</span> would I do it?\n … \r\n </div>\r\n <div class="tags user-tags t-python t-python-2û7">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/python-2.7" class="post-tag" title="show questions tagged 'python-2.7'" rel="tag">python-2.7</a> </div>\r\n <div class="started fr">\r\nasked <span title="2012-07-23 14:54:25Z" class="relativetime">Jul 23 \'12</span> by <a href="/users/1541162/ivanhoifung">ivanhoifung</a> </div>\r\n </div>\r\n </div>\r\n\r\n <div class="question-summary search-result" id="question-summary-11923657" data-position="15">\r\n <div class="statscontainer">\r\n <div class="statsarrow"></div>\r\n <div class="stats">\r\n <div class="vote">\r\n <div class="votes ">\r\n <span class="vote-count-post "><strong>3</strong></span>\r\n <div class="viewcount">votes</div>\r\n </div>\r\n </div>\r\n <div class="status answered-accepted">\r\n <strong>2</strong>answers\r\n </div>\r\n </div>\r\n </div>\r\n <div class="summary">\r\n <div class="result-link">\r\n <span>\r\n <a href="/questions/11923657/python-find-integer-closest-to-0-in-list" data-searchsession="/questions/11923657/python-find-integer-closest-to-0-in-list?s=15|0.4109" title="Python - find integer closest to 0 in list">\r\n Q: Python - find integer closest to 0 in list [duplicate]\r\n </a>\r\n</span>\r\n </div>\r\n <div class="excerpt">\r\n \n Possible <span class="result-highlight">Duplicate</span>:\n finding index of an item closest to the value in a <span class="result-highlight">list</span> that's not entirely sorted \n\n\n\n\nI've got a <span class="result-highlight">list</span> of positive and negative numbers in <span class="result-highlight">Python</span> ([237, 72, -18, 237, 236 … , 237, 60, -158, -273, -78, 492, 243]). I want to <span class="result-highlight">find</span> the number which is closest to 0. <span class="result-highlight">How</span> do I do this?\n … \r\n </div>\r\n <div class="tags user-tags t-python t-algorithm t-list t-numbers">\r\n<a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a> <a href="/questions/tagged/algorithm" class="post-tag" title="show questions tagged 'algorithm'" rel="tag">algorithm</a> <a href="/questions/tagged/list" class="post-tag" title="show questions tagged 'list'" rel="tag">list</a> <a href="/questions/tagged/numbers" class="post-tag" title="show questions tagged 'numbers'" rel="tag">numbers</a> </div>\r\n <div class="started fr">\r\nasked <span title="2012-08-12 16:09:37Z" class="relativetime">Aug 12 \'12</span> by <a href="/users/985616/gadgetmo">gadgetmo</a> </div>\r\n </div>\r\n </div>\r\n </div>\r\n <br class="cbt">\r\n<div class="pager fl">\r\n \r\n\r\n\r\n\r\n\r\n <span class="page-numbers current">1</span> <a href="/search?page=2&tab=relevance&q=how%20to%20find%20duplicates%20in%20list%20python" title="go to page 2"> <span class="page-numbers">2</span> </a> \r\n <a href="/search?page=3&tab=relevance&q=how%20to%20find%20duplicates%20in%20list%20python" title="go to page 3"> <span class="page-numbers">3</span> </a> \r\n <a href="/search?page=4&tab=relevance&q=how%20to%20find%20duplicates%20in%20list%20python" title="go to page 4"> <span class="page-numbers">4</span> </a> \r\n <a href="/search?page=5&tab=relevance&q=how%20to%20find%20duplicates%20in%20list%20python" title="go to page 5"> <span class="page-numbers">5</span> </a> \r\n <span class="page-numbers dots">\xe2\x80\xa6</span> <a href="/search?page=11&tab=relevance&q=how%20to%20find%20duplicates%20in%20list%20python" title="go to page 11"> <span class="page-numbers">11</span> </a> \r\n <a href="/search?page=2&tab=relevance&q=how%20to%20find%20duplicates%20in%20list%20python" rel="next" title="go to page 2"> <span class="page-numbers next"> next</span> </a> \r\n\r\n </div><div class="page-sizer fr">\r\n <a href="/search?tab=relevance&pagesize=15&q=how%20to%20find%20duplicates%20in%20list%20python" title="show 15 items per page" class="page-numbers current">15</a>\r\n <a href="/search?tab=relevance&pagesize=30&q=how%20to%20find%20duplicates%20in%20list%20python" title="show 30 items per page" class="page-numbers ">30</a>\r\n <a href="/search?tab=relevance&pagesize=50&q=how%20to%20find%20duplicates%20in%20list%20python" title="show 50 items per page" class="page-numbers ">50</a>\r\n <span class="page-numbers desc">per page</span>\r\n </div></div>\r\n<div id="sidebar">\r\n \n<div class="aside-cta">\n <a href="/questions/ask" class="btn-outlined">Ask Question</a>\n</div>\r\n \r\n <div class="module search-module">\r\n <div class="search-side-top al">\r\n <a href="#" class="advanced-tips-toggle">Advanced Search Tips</a>\r\n <div class="advanced-tips">\r\n <table>\r\n <tr title="Search within a tag (can use more than one)"><td>tags</td><td>[tag]</td></tr>\r\n\r\n <tr title="Search for an exact phrase (can use more than one)" class="new-group"><td>exact</td><td>"words here"</td></tr>\r\n\r\n <tr title="Search within a user's posts" class="new-group"><td>author</td><td>user:1234</td></tr>\r\n <tr title="Search within your posts"><td></td><td>user:me <span class="advanced-note">(yours)</span></td></tr>\r\n\r\n <tr title="Search posts with a score of 3 or higher" class="new-group"><td>score</td><td>score:3 <span class="advanced-note">(3+)</span></td></tr>\r\n <tr title="Search posts with a score of 0"><td></td><td>score:0 <span class="advanced-note">(none)</span></td></tr>\r\n\r\n\r\n <tr title="Search questions with at least 3 answers" class="new-group"><td>answers</td><td>answers:3 <span class="advanced-note">(3+)</span></td></tr>\r\n <tr title="Search questions with no answers"><td></td><td>answers:0 <span class="advanced-note">(none)</span></td></tr>\r\n <tr title="Search only accepted answers (yes)\r\nSearch only answers that have not been accepted (no)">\r\n <td></td>\r\n <td>isaccepted:yes</td>\r\n </tr>\r\n <tr title="Search questions with an accepted answer (yes)\r\nSearch questions without an accepted answer (no)">\r\n <td></td>\r\n <td>hasaccepted:no</td>\r\n </tr>\r\n\r\n <tr title="Search answers to a question\r\n(or use "inquestion:this" from a question page)">\r\n <td></td>\r\n <td>inquestion:1234</td>\r\n </tr>\r\n\r\n <tr title="Search questions with at least 250 views" class="new-group"><td>views</td><td>views:250</td></tr>\r\n\r\n <tr title="Search only within titles" class="new-group"><td>sections</td><td>title:apples</td></tr>\r\n <tr title="Search only within post bodies"><td></td><td>body:"apples oranges"</td></tr>\r\n\r\n <tr title="Find links or images in posts" class="new-group"><td>url</td><td>url:"*.example.com"</td></tr>\r\n\r\n <tr title="Search questions favorited by you" class="new-group"><td>favorites</td><td>infavorites:mine</td></tr>\r\n <tr title="Search questions favorited by user 1234"><td></td><td>infavorites:1234</td></tr>\r\n\r\n <tr title="Search questions that are closed (yes)\r\nSearch questions that are not closed (no)" class="new-group">\r\n <td>status</td>\r\n <td>closed:yes</td>\r\n </tr>\r\n <tr title="Search questions that are closed as duplicates (yes)\r\nSearch questions that are not closed as duplicates (no)">\r\n <td></td>\r\n <td>duplicate:no</td>\r\n </tr>\r\n <tr title="Search posts that are migrated (yes)\r\nSearch posts that are not migrated (no)">\r\n <td></td>\r\n <td>migrated:no</td>\r\n </tr>\r\n <tr title="Search for community wiki posts (yes)\r\nSearch for non-community wiki posts (no)">\r\n <td></td>\r\n <td>wiki:no</td>\r\n </tr>\r\n <tr title="Search only questions" class="new-group"><td>types</td><td>is:question</td></tr>\r\n <tr title="Search only answers"><td></td><td>is:answer</td></tr>\r\n\r\n <tr title="Exclude words or tags" class="new-group"><td>exclude</td><td>-[tag]</td></tr>\r\n <tr title="Exclude words or tags"><td></td><td>-apples</td></tr>\r\n </table>\r\n <div>For more details on advanced search <a href="/help/searching">visit our help page</a></div>\r\n </div>\r\n </div>\r\n <p class="side-desc">results found containing</p>\r\n <p><span class="result-highlight">how to find duplicates in list python</span></p>\r\n </div>\r\n<script>\r\n var ados = ados || {}; ados.run = ados.run || [];\r\n ados.run.push(function () { ados_add_placement(22,8277,"adzerk457149888",[5,17,2221]).setZone(45); });\r\n </script>\r\n <div class="everyonelovesstackoverflow" id="adzerk457149888"></div>\r\n <div id="hireme"></div>\r\n <script>\r\nwindow.clc_request = \'Au0KYVupYdQIAAAAAAAAAAACAAAAAQAAAAAAAAAAABbwHgqAxUbbDE4\';\r\n;(function(n){var t,u,r,i;try{if(typeof[].indexOf!="function")return;if(window.attachEvent&&!window.addEventListener)return;if(n.allowed[0]!=="*"&&n.allowed.indexOf(location.hostname)===-1)return;if(t=window,t.clc=t.clc||{},u=t.clc_request||t.clcfl_request,u||console.warn("clc_request missing"),t.clc.init=t.clc.init||[],t.clc.init.push(function(n){return n.load()}),t.clc.options){for(r in t.clc.options)n[r]=t.clc.options[r];t.clc.options=n}else t.clc.options=n;i=document.createElement("script");i.async=!0;i.src=n.lib;document.body.appendChild(i)}catch(f){console.error("[clc] Error in loader:",f)}}).call(null, {"azw":true,"kt":2000,"tto":true,"autoload":true,"d":{"sb":["hireme","clc-sb"],"tlb":["careers1","clc-tlb"],"mlb":["careers3","clc-mlb"]},"allowed":["stackoverflow.com","serverfault.com","blog.codinghorror.com","talent.stackoverflow.com"],"h":"clc.stackoverflow.com","u":"https://clc.stackoverflow.com/markup.js","lib":"https://cdn.sstatic.net/clc/clc.min.js?v=bd570ea4a858"}); </script><div id="hot-network-questions" class="module tex2jax_ignore">\r\n <h4>\r\n <a href="//stackexchange.com/questions?tab=hot" \r\n class="js-gps-track" \r\n data-gps-track="posts_hot_network.click({ item_type:1, location:12 })">\r\n Hot Network Questions\r\n </a>\r\n </h4>\r\n <ul>\r\n <li >\r\n <div class="favicon favicon-codegolf" title="Programming Puzzles & Code Golf Stack Exchange"></div><a href="http://codegolf.stackexchange.com/questions/111861/draw-the-arc-of-a-ball" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:200 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Draw the arc of a ball\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-rpg" title="Role-playing Games Stack Exchange"></div><a href="http://rpg.stackexchange.com/questions/95876/does-a-tower-shield-providing-total-cover-in-a-5-foot-doorway-block-channel-ener" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:122 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Does a Tower Shield providing Total Cover in a 5-foot doorway block Channel Energy from going through?\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-mechanics" title="Motor Vehicle Maintenance & Repair Stack Exchange"></div><a href="http://mechanics.stackexchange.com/questions/42475/rotor-replacement-one-or-both" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:224 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Rotor replacement, one or both?\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-aviation" title="Aviation Stack Exchange"></div><a href="http://aviation.stackexchange.com/questions/35958/what-is-the-story-of-this-aircraft" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:528 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n What is the story of this aircraft?\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-mathematica" title="Mathematica Stack Exchange"></div><a href="http://mathematica.stackexchange.com/questions/139040/how-to-use-chartingscaledframeticks-to-produce-tick-specifications-for-log-scal" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:387 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n How to use Charting`ScaledFrameTicks to produce tick specifications for log-scaled plots?\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-pm" title="Project Management Stack Exchange"></div><a href="http://pm.stackexchange.com/questions/21176/how-to-efficiently-manage-a-scrum-team-when-team-members-are-of-different-veloci" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:208 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n How to efficiently manage a Scrum team when team members are of different velocities?\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-stats" title="Cross Validated"></div><a href="http://stats.stackexchange.com/questions/265024/what-does-a-s-stand-for" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:65 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n What does "a.s." stand for?\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-cooking" title="Seasoned Advice"></div><a href="http://cooking.stackexchange.com/questions/78835/question-about-over-medium-eggs" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:49 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Question about over medium eggs?\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-unix" title="Unix & Linux Stack Exchange"></div><a href="http://unix.stackexchange.com/questions/348714/is-it-possible-to-use-grep-to-pick-up-only-full-words" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:106 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Is it possible to use grep to pick up only full words?\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-crypto" title="Cryptography Stack Exchange"></div><a href="http://crypto.stackexchange.com/questions/44353/how-is-homomorphic-encryption-secure-over-integers" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:281 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n How is Homomorphic Encryption secure (over integers)?\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-politics" title="Politics Stack Exchange"></div><a href="http://politics.stackexchange.com/questions/16025/why-are-gun-restrictions-based-on-terror-watch-list-and-mental-health-so-controv" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:475 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Why are gun restrictions based on terror watch list and mental health so controversial in the US?\r\n </a>\r\n\r\n </li>\r\n <li >\r\n <div class="favicon favicon-space" title="Space Exploration Stack Exchange"></div><a href="http://space.stackexchange.com/questions/20440/have-space-station-modules-already-been-replaced" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:508 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Have space station modules already been replaced?\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-travel" title="Travel Stack Exchange"></div><a href="http://travel.stackexchange.com/questions/89017/why-would-i-want-a-hard-shell-suitcase-for-air-travel" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:273 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Why would I want a hard-shell suitcase (for air travel)?\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-ell" title="English Language Learners Stack Exchange"></div><a href="http://ell.stackexchange.com/questions/121168/in-how-many-ways-can-something-not-be-right" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:481 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n In how many ways can something not be right?\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-dba" title="Database Administrators Stack Exchange"></div><a href="http://dba.stackexchange.com/questions/165984/database-full-backup-maintenance-task-has-large-delay-between-databases" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:182 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Database Full Backup Maintenance Task has large delay between databases\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-scifi" title="Science Fiction & Fantasy Stack Exchange"></div><a href="http://scifi.stackexchange.com/questions/153748/2002-2003-pc-game-about-super-soldiers-winning-against-aliens-but-losing-earth-c" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:186 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n 2002/2003 PC Game about Super-soldiers winning against aliens but losing Earth coming back?\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-music" title="Music: Practice & Theory Stack Exchange"></div><a href="http://music.stackexchange.com/questions/53915/is-it-recommended-to-practice-sight-reading-by-feeling-out-the-music-instead-o" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:240 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Is it recommended to practice sight reading by "feeling out the music" instead of counting\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-security" title="Information Security Stack Exchange"></div><a href="http://security.stackexchange.com/questions/152765/how-to-recover-from-ransomware-using-restore-points" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:162 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n How to recover from ransomware using Restore Points?\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-unix" title="Unix & Linux Stack Exchange"></div><a href="http://unix.stackexchange.com/questions/348599/only-if-in-alias-ls-ls-i-test" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:106 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Only if in "/" : alias ls='ls -I test'?\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-scifi" title="Science Fiction & Fantasy Stack Exchange"></div><a href="http://scifi.stackexchange.com/questions/153738/a-futuristic-book-i-am-sure-was-titled-grandfather-bank" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:186 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n A futuristic book I am sure was titled "Grandfather Bank"\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-scifi" title="Science Fiction & Fantasy Stack Exchange"></div><a href="http://scifi.stackexchange.com/questions/153673/why-didnt-snape-just-kill-voldemort-to-buy-more-time-while-the-latter-was-recup" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:186 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Why didn't Snape just kill Voldemort to buy more time while the latter was recuperating as a Horcrux?\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-math" title="Mathematics Stack Exchange"></div><a href="http://math.stackexchange.com/questions/2168152/multiplication-of-functions-results-in-0-but-none-of-the-functions-is-0" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:69 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n Multiplication of functions results in 0 but none of the functions is 0\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-politics" title="Politics Stack Exchange"></div><a href="http://politics.stackexchange.com/questions/16051/how-does-obamacare-save-lives" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:475 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n How does Obamacare save lives?\r\n </a>\r\n\r\n </li>\r\n <li class="dno js-hidden">\r\n <div class="favicon favicon-tex" title="TeX - LaTeX Stack Exchange"></div><a href="http://tex.stackexchange.com/questions/356575/how-do-i-use-align-here-there-are-two-stages-i-need-to-align" class="js-gps-track" data-gps-track="site.switch({ item_type:12, target_site:85 }); posts_hot_network.click({ item_type:2, location:12 })">\r\n How do I use align here? There are "two stages" I need to align\r\n </a>\r\n\r\n </li>\r\n </ul>\r\n\r\n <a href="#" \r\n class="show-more js-show-more js-gps-track" \r\n data-gps-track="posts_hot_network.click({ item_type:3, location:12 })">\r\n more hot questions\r\n </a>\r\n</div></div>\r\n <script>\r\n $(".js-search-results").on("mousedown touchstart", "div.result-link a", function (ev) {\r\n this.href = $(this).data("searchsession");\r\n });\r\n </script>\r\n\r\n </div>\r\n </div>\r\n <div id="footer" class="categories">\r\n <div class="footerwrap"> \r\n <div id="footer-menu">\r\n <div class="top-footer-links">\r\n <a href="http://stackoverflow.com/company/about">about us</a>\r\n <a href="/tour">tour</a>\r\n <a href="/help">help</a>\r\n <a href="http://stackoverflow.blog?blb=1">blog</a>\r\n <a href="http://chat.stackoverflow.com">chat</a>\r\n <a href="http://data.stackexchange.com">data</a>\r\n <a href="http://stackexchange.com/legal">legal</a>\r\n <a href="http://stackexchange.com/legal/privacy-policy">privacy policy</a>\r\n <a href="http://stackoverflow.com/company/work-here">work here</a>\r\n <a href="https://www.stackoverflowbusiness.com/advertise">advertising info</a>\r\n <a href="http://stackoverflow.com/jobs/directory/developer-jobs">developer jobs directory</a>\r\n\r\n <a onclick=\'StackExchange.switchMobile("on")\'>mobile</a>\r\n <b><a href="/contact">contact us</a></b>\r\n <b><a href="http://meta.stackoverflow.com">feedback</a></b>\r\n \r\n </div>\r\n <div id="footer-sites">\r\n <table>\r\n <tr>\r\n <th colspan=3>\r\n Technology\r\n </th>\r\n <th >\r\n Life / Arts\r\n </th>\r\n <th >\r\n Culture / Recreation\r\n </th>\r\n <th >\r\n Science\r\n </th>\r\n <th >\r\n Other\r\n </th>\r\n </tr>\r\n <tr>\r\n <td>\r\n <ol>\r\n <li><a href="//stackoverflow.com" title="professional and enthusiast programmers">Stack Overflow</a></li>\r\n <li><a href="//serverfault.com" title="system and network administrators">Server Fault</a></li>\r\n <li><a href="//superuser.com" title="computer enthusiasts and power users">Super User</a></li>\r\n <li><a href="//webapps.stackexchange.com" title="power users of web applications">Web Applications</a></li>\r\n <li><a href="//askubuntu.com" title="Ubuntu users and developers">Ask Ubuntu</a></li>\r\n <li><a href="//webmasters.stackexchange.com" title="pro webmasters">Webmasters</a></li>\r\n <li><a href="//gamedev.stackexchange.com" title="professional and independent game developers">Game Development</a></li>\r\n <li><a href="//tex.stackexchange.com" title="users of TeX, LaTeX, ConTeXt, and related typesetting systems">TeX - LaTeX</a></li>\r\n <li><a href="//softwareengineering.stackexchange.com" title="professionals, academics, and students working within the systems development life cycle who care about creating, delivering, and maintaining software responsibly">Software Engineering</a></li>\r\n <li><a href="//unix.stackexchange.com" title="users of Linux, FreeBSD and other Un*x-like operating systems">Unix & Linux</a></li>\r\n <li><a href="//apple.stackexchange.com" title="power users of Apple hardware and software">Ask Different (Apple)</a></li>\r\n <li><a href="//wordpress.stackexchange.com" title="WordPress developers and administrators">WordPress Development</a></li>\r\n </ol></td><td><ol>\r\n <li><a href="//gis.stackexchange.com" title="cartographers, geographers and GIS professionals">Geographic Information Systems</a></li>\r\n <li><a href="//electronics.stackexchange.com" title="electronics and electrical engineering professionals, students, and enthusiasts">Electrical Engineering</a></li>\r\n <li><a href="//android.stackexchange.com" title="enthusiasts and power users of the Android operating system">Android Enthusiasts</a></li>\r\n <li><a href="//security.stackexchange.com" title="information security professionals">Information Security</a></li>\r\n <li><a href="//dba.stackexchange.com" title="database professionals who wish to improve their database skills and learn from others in the community">Database Administrators</a></li>\r\n <li><a href="//drupal.stackexchange.com" title="Drupal developers and administrators">Drupal Answers</a></li>\r\n <li><a href="//sharepoint.stackexchange.com" title="SharePoint enthusiasts">SharePoint</a></li>\r\n <li><a href="//ux.stackexchange.com" title="user experience researchers and experts">User Experience</a></li>\r\n <li><a href="//mathematica.stackexchange.com" title="users of Wolfram Mathematica">Mathematica</a></li>\r\n <li><a href="//salesforce.stackexchange.com" title="Salesforce administrators, implementation experts, developers and anybody in-between">Salesforce</a></li>\r\n <li><a href="//expressionengine.stackexchange.com" title="administrators, end users, developers and designers for ExpressionEngine® CMS">ExpressionEngine® Answers</a></li>\r\n <li><a href="//crypto.stackexchange.com" title="software developers, mathematicians and others interested in cryptography">Cryptography</a></li>\r\n </ol></td><td><ol>\r\n <li><a href="//codereview.stackexchange.com" title="peer programmer code reviews">Code Review</a></li>\r\n <li><a href="//magento.stackexchange.com" title="users of the Magento e-Commerce platform">Magento</a></li>\r\n <li><a href="//dsp.stackexchange.com" title="practitioners of the art and science of signal, image and video processing">Signal Processing</a></li>\r\n <li><a href="//raspberrypi.stackexchange.com" title="users and developers of hardware and software for Raspberry Pi">Raspberry Pi</a></li>\r\n <li><a href="//codegolf.stackexchange.com" title="programming puzzle enthusiasts and code golfers">Programming Puzzles & Code Golf</a></li>\r\n \r\n <li>\r\n <a href="http://stackexchange.com/sites#technology" class="more">\r\n more (7)\r\n </a>\r\n </li>\r\n </ol>\r\n </td>\r\n <td>\r\n <ol>\r\n <li><a href="//photo.stackexchange.com" title="professional, enthusiast and amateur photographers">Photography</a></li>\r\n <li><a href="//scifi.stackexchange.com" title="science fiction and fantasy enthusiasts">Science Fiction & Fantasy</a></li>\r\n <li><a href="//graphicdesign.stackexchange.com" title="Graphic Design professionals, students, and enthusiasts">Graphic Design</a></li>\r\n <li><a href="//movies.stackexchange.com" title="movie and tv enthusiasts">Movies & TV</a></li>\r\n <li><a href="//music.stackexchange.com" title="musicians, students, and enthusiasts">Music: Practice & Theory</a></li>\r\n <li><a href="//cooking.stackexchange.com" title="professional and amateur chefs">Seasoned Advice (cooking)</a></li>\r\n <li><a href="//diy.stackexchange.com" title="contractors and serious DIYers">Home Improvement</a></li>\r\n <li><a href="//money.stackexchange.com" title="people who want to be financially literate">Personal Finance & Money</a></li>\r\n <li><a href="//academia.stackexchange.com" title="academics and those enrolled in higher education">Academia</a></li>\r\n \r\n <li>\r\n <a href="http://stackexchange.com/sites#lifearts" class="more">\r\n more (8)\r\n </a>\r\n </li>\r\n </ol>\r\n </td>\r\n <td>\r\n <ol>\r\n <li><a href="//english.stackexchange.com" title="linguists, etymologists, and serious English language enthusiasts">English Language & Usage</a></li>\r\n <li><a href="//skeptics.stackexchange.com" title="scientific skepticism">Skeptics</a></li>\r\n <li><a href="//judaism.stackexchange.com" title="those who base their lives on Jewish law and tradition and anyone interested in learning more">Mi Yodeya (Judaism)</a></li>\r\n <li><a href="//travel.stackexchange.com" title="road warriors and seasoned travelers">Travel</a></li>\r\n <li><a href="//christianity.stackexchange.com" title="committed Christians, experts in Christianity and those interested in learning more">Christianity</a></li>\r\n <li><a href="//ell.stackexchange.com" title="speakers of other languages learning English">English Language Learners</a></li>\r\n <li><a href="//japanese.stackexchange.com" title="students, teachers, and linguists wanting to discuss the finer points of the Japanese language">Japanese Language</a></li>\r\n <li><a href="//gaming.stackexchange.com" title="passionate videogamers on all platforms">Arqade (gaming)</a></li>\r\n <li><a href="//bicycles.stackexchange.com" title="people who build and repair bicycles, people who train cycling, or commute on bicycles">Bicycles</a></li>\r\n <li><a href="//rpg.stackexchange.com" title="gamemasters and players of tabletop, paper-and-pencil role-playing games">Role-playing Games</a></li>\r\n <li><a href="//anime.stackexchange.com" title="anime and manga fans">Anime & Manga</a></li>\r\n <li><a href="//mechanics.stackexchange.com" title="mechanics and DIY enthusiast owners of cars, trucks, and motorcycles">Motor Vehicle Maintenance & Repair</a></li>\r\n \r\n <li>\r\n <a href="http://stackexchange.com/sites#culturerecreation" class="more">\r\n more (17)\r\n </a>\r\n </li>\r\n </ol>\r\n </td>\r\n <td>\r\n <ol>\r\n <li><a href="//mathoverflow.net" title="professional mathematicians">MathOverflow</a></li>\r\n <li><a href="//math.stackexchange.com" title="people studying math at any level and professionals in related fields">Mathematics</a></li>\r\n <li><a href="//stats.stackexchange.com" title="people interested in statistics, machine learning, data analysis, data mining, and data visualization">Cross Validated (stats)</a></li>\r\n <li><a href="//cstheory.stackexchange.com" title="theoretical computer scientists and researchers in related fields">Theoretical Computer Science</a></li>\r\n <li><a href="//physics.stackexchange.com" title="active researchers, academics and students of physics">Physics</a></li>\r\n <li><a href="//chemistry.stackexchange.com" title="scientists, academics, teachers and students">Chemistry</a></li>\r\n <li><a href="//biology.stackexchange.com" title="biology researchers, academics, and students">Biology</a></li>\r\n <li><a href="//cs.stackexchange.com" title="students, researchers and practitioners of computer science">Computer Science</a></li>\r\n <li><a href="//philosophy.stackexchange.com" title="those interested in the study of the fundamental nature of knowledge, reality, and existence">Philosophy</a></li>\r\n \r\n <li>\r\n <a href="http://stackexchange.com/sites#science" class="more">\r\n more (3)\r\n </a>\r\n </li>\r\n </ol>\r\n </td>\r\n <td>\r\n <ol>\r\n <li><a href="//meta.stackexchange.com" title="meta-discussion of the Stack Exchange family of Q&A websites">Meta Stack Exchange</a></li>\r\n <li><a href="//stackapps.com" title="apps, scripts, and development with the Stack Exchange API">Stack Apps</a></li>\r\n <li><a href="//area51.stackexchange.com" title="proposing new sites in the Stack Exchange network">Area 51</a></li>\r\n <li><a href="https://www.stackoverflowbusiness.com/talent">Stack Overflow Talent</a></li>\r\n \r\n </ol>\r\n </td>\r\n </tr>\r\n</table>\r\n </div>\r\n </div>\r\n <div id="copyright">\r\n site design / logo © 2017 Stack Exchange Inc; user contributions licensed under <a href="https://creativecommons.org/licenses/by-sa/3.0/" rel="license">cc by-sa 3.0</a> \r\n with <a href="http://blog.stackoverflow.com/2009/06/attribution-required/" rel="license">attribution required</a>\r\n </div>\r\n <div id="svnrev">\r\n rev 2017.3.2.25275\r\n </div>\r\n </div>\r\n </div>\r\n <noscript>\r\n <div id="noscript-warning">Stack Overflow works best with JavaScript enabled<img src="https://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif" alt="" class="dno"></div>\r\n </noscript>\r\n\r\n<script>var p = "http", d = "static"; if (document.location.protocol == "https:") { p += "s"; d = "engine"; } var z = document.createElement("script"); z.type = "text/javascript"; z.async = true; z.src = p + "://" + d + ".adzerk.net/ados.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(z, s);</script>\r\n<script>\r\n var ados = ados || {};\r\n ados.run = ados.run || [];\r\n \r\n \r\n \r\n ados.run.push(function () {\r\n setTimeout(function () { $("#adzerk-user-match").remove(); }, window.AUMIframeDone ? 0 : 2000);\r\n ; ados_load();\r\n }); \r\n \r\n</script>\r\n\r\n <script>\r\n (function(i, s, o, g, r, a, m) {\r\n i[\'GoogleAnalyticsObject\'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o),\r\n m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m);\r\n })(window, document, \'script\', \'https://www.google-analytics.com/analytics.js\', \'ga\');\r\n ga(\'create\', \'UA-5620270-1\');\r\n ga(\'create\', \'UA-5620270-60\', {name: \'pageData\', sampleRate: 100 });\r\n ga(\'send\', \'pageview\');\r\n ga(\'pageData.send\', \'pageview\');\r\n var _qevents = _qevents || [],\r\n _comscore = _comscore || [];\r\n (function () {\r\n var ssl=\'https:\'==document.location.protocol,\r\n s=document.getElementsByTagName(\'script\')[0],\r\n qc=document.createElement(\'script\');\r\n qc.async = true;\r\n qc.src = (ssl ? \'https://secure\' : \'http://edge\') + \'.quantserve.com/quant.js\';\r\n s.parentNode.insertBefore(qc, s);\r\n _qevents.push({ qacct: "p-c1rF4kxgLUzNc" });\r\n var sc=document.createElement(\'script\');\r\n sc.async=true;\r\n sc.src=(ssl?\'https://sb\':\'http://b\') + \'.scorecardresearch.com/beacon.js\';\r\n s.parentNode.insertBefore(sc, s);\r\n _comscore.push({ c1: "2", c2: "17440561" });\r\n })();\r\n\r\n </script>\r\n \r\n \r\n <script type="text/javascript">\r\n \r\n (function(appendChild) {\r\n Node.prototype.appendChild = function() {\r\n var parent = this;\r\n var newNode = arguments[0];\r\n if (parent.nodeName === \'HEAD\'\r\n && newNode\r\n && newNode.nodeName === \'SCRIPT\'\r\n && newNode.src) {\r\n \r\n window.setTimeout(function() {\r\n var result = newNode.src.match(/^https:\\/\\/maps\\.googleapis\\.com\\/maps\\/api\\/place\\/js\\/(\\w+)Service\\./i) || [];\r\n var service = result[1];\r\n if (service) {\r\n if (service === \'Autocompletion\') service = 2;\r\n else if (service === \'Place\') service = 1;\r\n else service = 0;\r\n StackExchange.using(\'gps\', function() {\r\n StackExchange.gps.track(\'google_maps_places_api.call\', { service: service });\r\n });\r\n }\r\n }, 0);\r\n }\r\n return appendChild.apply(this, arguments);\r\n };\r\n })(Node.prototype.appendChild);\r\n </script>\r\n </body>\r\n</html>'
In [4]:
import bs4
soup = bs4.BeautifulSoup(html)
/home/zzz/anaconda2/lib/python2.7/site-packages/bs4/__init__.py:181: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
The code that caused this warning is on line 174 of the file /home/zzz/anaconda2/lib/python2.7/runpy.py. To get rid of this warning, change code that looks like this:
BeautifulSoup([your markup])
to this:
BeautifulSoup([your markup], "lxml")
markup_type=markup_type))
In [147]:
search_results = soup.findAll(attrs={'class':'question-summary search-result'},limit=10)
In [168]:
search_results[0]
Out[168]:
<div class="question-summary search-result" data-position="1" id="question-summary-26189496">\n<div class="statscontainer">\n<div class="statsarrow"></div>\n<div class="stats">\n<div class="vote">\n<div class="votes ">\n<span class="vote-count-post "><strong>1</strong></span>\n<div class="viewcount">vote</div>\n</div>\n</div>\n<div class="status answered-accepted">\n<strong>2</strong>answers\r\n </div>\n</div>\n</div>\n<div class="summary">\n<div class="result-link">\n<span>\n<a data-searchsession="/questions/26189496/how-to-find-duplicates-values-in-list-python?s=1|1.5947" href="/questions/26189496/how-to-find-duplicates-values-in-list-python" title="How to find duplicates values in list Python">\r\n Q: How to find duplicates values in list Python \r\n </a>\n</span>\n</div>\n<div class="excerpt">\r\n I was wondering <span class="result-highlight">how</span> can I know if when a user inputs a value, that value already exists in a <span class="result-highlight">list</span>.\n\nFor example;\n\nlis = ['foo', 'boo', 'hoo']\n\n\nuser inputs:\n\n'boo'\n\n\nNow my question is <span class="result-highlight">how</span> can I tell the user this value already exists inside the <span class="result-highlight">list</span>.\n \u2026 \r\n </div>\n<div class="tags user-tags t-python t-list t-duplicates">\n<a class="post-tag" href="/questions/tagged/python" rel="tag" title="show questions tagged 'python'">python</a> <a class="post-tag" href="/questions/tagged/list" rel="tag" title="show questions tagged 'list'">list</a> <a class="post-tag" href="/questions/tagged/duplicates" rel="tag" title="show questions tagged 'duplicates'">duplicates</a> </div>\n<div class="started fr">\r\nasked <span class="relativetime" title="2014-10-04 04:05:57Z">Oct 4 '14</span> by <a href="/users/3973873/andre">Andre</a> </div>\n</div>\n</div>
In [7]:
with open('this_html.html', 'w') as outfile:
outfile.write(html)
In [227]:
title=[res.find(attrs={'class':'result-link'}).span.text.strip() for res in search_results]
time=[res.find(attrs={'class':'relativetime'}).text.strip() for res in search_results]
ans=[res.find(attrs={'class':'status answered-accepted'}) for res in search_results]
c=[]
for b in ans:
c.append(b.text.strip().replace('answer',' answer') if b!=None else u'0 answer')
link=[res.find(attrs={'class':'result-link'}).a['data-searchsession'] for res in search_results]
link=["<http://stackoverflow.com"+i+">" for i in link]
In [228]:
zip(title,time,c,link)
Out[228]:
[(u'Q: How to find duplicates values in list Python',
u"Oct 4 '14",
u'2 answers',
'<http://stackoverflow.com/questions/26189496/how-to-find-duplicates-values-in-list-python?s=1|1.5947>'),
(u'Q: python algorithm, find duplicates in list [closed]',
u"Jan 2 '14",
u'2 answers',
'<http://stackoverflow.com/questions/20881716/python-algorithm-find-duplicates-in-list?s=2|1.1658>'),
(u'Q: Python - How to find and merge duplicates in list of addresses (which are lists themselves)',
u'Jan 10',
u'2 answers',
'<http://stackoverflow.com/questions/41576429/python-how-to-find-and-merge-duplicates-in-list-of-addresses-which-are-lists?s=3|1.1459>'),
(u'Q: How to find a duplicate in a list without using set in python?',
u"Feb 21 '14",
u'7 answers',
'<http://stackoverflow.com/questions/21925497/how-to-find-a-duplicate-in-a-list-without-using-set-in-python?s=4|1.0777>'),
(u'Q: How to find duplicates in a python list that are adjacent to each other and list them with r\u2026',
u"Jun 25 '15",
u'3 answers',
'<http://stackoverflow.com/questions/31047647/how-to-find-duplicates-in-a-python-list-that-are-adjacent-to-each-other-and-list?s=5|1.0348>'),
(u'Q: How to find out if there are any duplicates in list of lists',
u"Apr 7 '14",
u'3 answers',
'<http://stackoverflow.com/questions/22923084/how-to-find-out-if-there-are-any-duplicates-in-list-of-lists?s=6|0.9202>'),
(u'Q: How to find a duplicate in a list without in-built functions in Python?',
u"Oct 25 '15",
u'2 answers',
'<http://stackoverflow.com/questions/33335058/how-to-find-a-duplicate-in-a-list-without-in-built-functions-in-python?s=7|0.9078>'),
(u'Q: Python : How to find duplicates in a list and update these duplicate items by renaming them \u2026',
u"Jun 19 '13",
u'0 answer',
'<http://stackoverflow.com/questions/17202444/python-how-to-find-duplicates-in-a-list-and-update-these-duplicate-items-by-re?s=8|0.8365>'),
(u'Q: Python optimize how to find duplicate value and value index in a list',
u"Apr 19 '15",
u'4 answers',
'<http://stackoverflow.com/questions/29733813/python-optimize-how-to-find-duplicate-value-and-value-index-in-a-list?s=9|0.7297>'),
(u'Q: Replacing ONE specific duplicate in list of duplicates in python',
u'Jan 25',
u'0 answer',
'<http://stackoverflow.com/questions/41862084/replacing-one-specific-duplicate-in-list-of-duplicates-in-python?s=10|0.5823>')]
In [226]:
ans=[res.find(attrs={'class':'status answered-accepted'}) for res in search_results]
c=[]
for b in ans:
c.append(b.text.strip().replace('answer',' answer') if b!=None else u'0 answer')
c
Out[226]:
[u'2 answers',
u'2 answers',
u'2 answers',
u'7 answers',
u'3 answers',
u'3 answers',
u'2 answers',
u'0 answer',
u'4 answers',
u'0 answer']
In [222]:
str(search_results[0])[1915:2032]
Out[222]:
''
In [223]:
sr = search_results[0]
In [16]:
sr
Out[16]:
<li class="regular-search-result">\n<div class="search-result natural-search-result" data-key="1">\n<div class="biz-listing-large">\n<div class="main-attributes">\n<div class="media-block media-block--12">\n<div class="media-avatar">\n<div class="photo-box pb-90s">\n<a class="js-analytics-click" data-analytics-label="biz-photo" href="/biz/pho-nomenon-noodle-and-grill-hoboken?osq=vietnamese+food">\n<img alt="Pho Nomenon Noodle & Grill" class="photo-box-img" height="90" src="https://s3-media3.fl.yelpcdn.com/bphoto/zWyVwZdyyjEuDBmlfL4T5A/90s.jpg" width="90"/>\n</a>\n</div>\n</div>\n<div class="media-story">\n<h3 class="search-result-title">\n<span class="indexed-biz-name">1. <a class="biz-name js-analytics-click" data-analytics-label="biz-name" data-hovercard-id="HblDdwBZIP7F1dYH5JRBag" href="/biz/pho-nomenon-noodle-and-grill-hoboken?osq=vietnamese+food"><span>Pho Nomenon Noodle & Grill</span></a>\n</span>\n</h3>\n<div class="biz-rating biz-rating-large clearfix">\n<div class="i-stars i-stars--regular-3 rating-large" title="3.0 star rating">\n<img alt="3.0 star rating" class="offscreen" height="303" src="https://s3-media1.fl.yelpcdn.com/assets/srv0/yelp_design_web/41341496d9db/assets/img/stars/stars.png" width="84"/>\n</div>\n<span class="review-count rating-qualifier">\n 163 reviews\n </span>\n</div>\n<div class="price-category">\n<span class="bullet-after">\n<span class="business-attribute price-range">$</span>\n</span>\n<span class="category-str-list">\n<a href="/search?find_desc=vietnamese+food&find_loc=Hoboken&cflt=vietnamese">Vietnamese</a>,\n <a href="/search?find_desc=vietnamese+food&find_loc=Hoboken&cflt=noodles">Noodles</a>\n</span>\n</div>\n<ul class="search-result_tags">\n</ul>\n</div>\n</div>\n</div>\n<div class="secondary-attributes">\n<address>\n 516 Washington St<br/>Hoboken, NJ 07030\n </address>\n<span class="offscreen">Phone number</span>\n<span class="biz-phone">\n (201) 706-8554\n </span>\n</div>\n</div>\n<div class="search-result-ctas u-space-t1">\n<div class="search-avatar-offset js-platform">\n<div class="island island--slim search-result-cta">\n<div class="arrange arrange--middle arrange--6">\n<div class="arrange_unit">\n<span aria-hidden="true" class="icon icon--18-order icon--size-18" style="fill: #ca6d00; width: 18px; height: 18px;">\n<svg class="icon_svg">\n<use xlink:href="#18x18_order"></use>\n</svg>\n</span>\n</div>\n<div class="arrange_unit--fill arrange_unit cta-text">\n<span class="">\n This restaurant accepts pickup and delivery\n </span>\n</div>\n<div class="arrange_unit nowrap js-tag-action" data-business-id="OE9bjWdWyo530-Nj3dIILw" data-popup-title="" data-search-action-uri="/transaction_platform/start_order/OE9bjWdWyo530-Nj3dIILw">\n<a class="ybtn ybtn--small low-intent-search-action-button" href="javascript:;">Start Order</a>\n</div>\n</div>\n</div>\n<div class="search-result-cta-error-row">\n<div class="platform-vsearch-error-message text-error">\n</div>\n</div>\n</div>\n</div>\n<div class="snippet-block media-block">\n<div class="media-avatar">\n<div class="photo-box pb-30s" data-hovercard-id="daCCXEk5YQLmzwdIvUeeDw">\n<a href="/user_details?userid=5mdS-QvefXD0EhYDqiSrdA">\n<img alt="Kelly N." class="photo-box-img" height="30" src="https://s3-media1.fl.yelpcdn.com/photo/YJFa28-3D0O4sVo9h4wyaA/30s.jpg" width="30"/>\n</a>\n</div>\n</div>\n<div class="media-story">\n<p class="snippet">\n having Chinese owners (who are really friendly, btw), the <span class="highlighted">food</span> still had those delicious <span class="highlighted">Vietnamese</span> flavors. My go-to is the grilled pork with white rice. I've definitely had better\u2026\n <a class="nowrap" href="/biz/pho-nomenon-noodle-and-grill-hoboken?hrid=flhdJjn0DwfeygIGh279cA&osq=vietnamese+food">read more</a>\n</p>\n</div>\n</div>\n</div>\n</li>
In [146]:
a=None
a if 1 else 0
In [ ]:
Content source: ZeroZeng/RongZeng
Similar notebooks: