{"id":33130,"date":"2023-02-04T18:54:11","date_gmt":"2023-02-04T13:24:11","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/"},"modified":"2023-02-04T18:54:11","modified_gmt":"2023-02-04T13:24:11","slug":"solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/","title":{"rendered":"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-34067660\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"34067660\" data-parentid=\"34064947\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>Some info on enumerate by typing <code>help(enumerate)<\/code><\/p>\n<blockquote>\n<p>enumerate(iterable[, start]) -&gt; iterator for index, value of iterable<\/p>\n<p>Return an enumerate object.  iterable must be another object that supports iteration.  The enumerate object yields pairs containing a count (from start, which defaults to zero) and a value yielded by the iterable argument. enumerate is useful for obtaining an indexed list:<\/p>\n<\/blockquote>\n<p>The <code>%<\/code> operator returns the remainder of <code>x \/ y<\/code> eg <\/p>\n<pre><code>10 \/ 5 = 2 r 0  |  10 % 5 = 0\n7  \/ 2 = 3 r 1  |  7 % 2 = 1\n<\/code><\/pre>\n<p>Here is the code explained with comments<\/p>\n<pre><code>while True: # Loop will continue until break is called\n    try:\n        number = input('Enter') #Asks user to input 7 digit number\n\n        # Checks if the length of the input\n            # If not 7 characters long\n            # Will then ask for input again due to while loop\n        if len(str(number)) != 7:\n            print('Incorrect')\n\n            # If is 7 chacters long\n        if len(str(number)) == 7:\n            print('Okay')\n            multiplier = [3,1]\n            times=\"\"\n            total = 0\n            # example input for number '1234567'\n            # list(str(number))\n            # '1234567' -&gt; ['1', '2', '3', '4', '5', '6', '7']\n            for index, digit in enumerate(list(str(number))):\n                # index%2 returns either 0 or 1\n                # this is used to get 3 or 1 from multiplier\n                # depending on if the index is odd or even\n\n                # for first index and digit from example\n                # index = 0, digit=\"1\"\n                # total = total + 1 * 3\n                total = total + int(digit)*multiplier[index%2]\n\n                # adds the multiplier value from digit * multiplier[index%2]\n                # to times as a string. First value is\n                # times = times + str(1 * 3) which is 3\n                times = times+str(int(digit)*multiplier[index%2])+', '\n            # essentially rounds up to nearest 10\n            mof10 = total + (10 - total%10)\n            # gets the number it was rounded up by\n            checkdigit = mof10 - total\n            final = str(number) + str(checkdigit)\n            print(times[:-1]) # slice the string to return everything except the last value\n            print(total)\n            print(mof10)\n            print(checkdigit)\n            print(final)\n            break # exit while loop\n        # If the convertion from string to int returns an error\n        # meaning a non-number was entered into input eg. !@#$\n        # print the following, while loop will continue and prompt again\n    except ValueError:\n        print('Not a number')\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">3<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Could someone please go through this code line by line and explain it in Pseudocode or English <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Some info on enumerate by typing help(enumerate) enumerate(iterable[, start]) -&gt; iterator for index, value of iterable Return an enumerate object. iterable must be another object that supports iteration. The enumerate object yields pairs containing a count (from start, which defaults to zero) and a value yielded by the iterable argument. enumerate is useful for &#8230; <a title=\"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/\" aria-label=\"More on [Solved] Could someone please go through this code line by line and explain it in Pseudocode or English\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[482],"class_list":["post-33130","post","type-post","status-publish","format-standard","hentry","category-solved","tag-python-3-x"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Some info on enumerate by typing help(enumerate) enumerate(iterable[, start]) -&gt; iterator for index, value of iterable Return an enumerate object. iterable must be another object that supports iteration. The enumerate object yields pairs containing a count (from start, which defaults to zero) and a value yielded by the iterable argument. enumerate is useful for ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-04T13:24:11+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\\\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/person\\\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English\",\"datePublished\":\"2023-02-04T13:24:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\\\/\"},\"wordCount\":111,\"publisher\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\"},\"keywords\":[\"python-3.x\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\\\/\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\\\/\",\"name\":\"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English - JassWeb\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#website\"},\"datePublished\":\"2023-02-04T13:24:11+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#website\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/jassweb.com\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/jass-website-logo-1.png\",\"contentUrl\":\"https:\\\/\\\/jassweb.com\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/person\\\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400\",\"contentUrl\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\\\/\\\/jassweb.com\"],\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/author\\\/jaspritsinghghumangmail-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English - JassWeb","og_description":"[ad_1] Some info on enumerate by typing help(enumerate) enumerate(iterable[, start]) -&gt; iterator for index, value of iterable Return an enumerate object. iterable must be another object that supports iteration. The enumerate object yields pairs containing a count (from start, which defaults to zero) and a value yielded by the iterable argument. enumerate is useful for ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/","og_site_name":"JassWeb","article_published_time":"2023-02-04T13:24:11+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English","datePublished":"2023-02-04T13:24:11+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/"},"wordCount":111,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["python-3.x"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/","url":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/","name":"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2023-02-04T13:24:11+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-could-someone-please-go-through-this-code-line-by-line-and-explain-it-in-pseudocode-or-english\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/33130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=33130"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/33130\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=33130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=33130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=33130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}