{"id":31546,"date":"2023-01-22T10:44:03","date_gmt":"2023-01-22T05:14:03","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/"},"modified":"2023-01-22T10:44:03","modified_gmt":"2023-01-22T05:14:03","slug":"solved-what-is-wrong-with-my-translator-python-closed","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/","title":{"rendered":"[Solved] What is wrong with my translator? (Python) [closed]"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-44959806\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"44959806\" data-parentid=\"44959722\" data-score=\"1\" 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>I assume you want something like:<\/p>\n<pre><code>def answer(plaintext):\n    words = {\"a\":'100000',\"b\":'110000',\"c\":'100100',\"d\":'100110',\"e\":'100010',\"f\":'110100',\"g\":'110110',\"h\":'110010',\"i\":'010100',\"j\":'010110',\"k\":'101000',\"l\":'111000',\"m\":'101100',\"n\":'101110',\"o\":'101010',\"p\":'111100',\"q\":'111110',\"r\":'111010',\"s\":'011100',\"t\":'011110',\"u\":'101001',\"v\":'111001',\"w\":'010111',\"x\":'010111',\"y\":'101011',\"z\":'101011'}\n    inputList = plaintext.split(',')\n    for word in inputList:\n        print words[word]\n\ntext = \"j,o,s,e\"\nanswer(text)\n<\/code><\/pre>\n<p>You had a bunch of typos in your <code>dict<\/code>, pay attention to the traceback, it tells you exactly what&#8217;s wrong. You also never actually called the function you defined. You probably want your <code>dict<\/code> values to be strings as well.<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">2<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved What is wrong with my translator? (Python) [closed] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] I assume you want something like: def answer(plaintext): words = {&#8220;a&#8221;:&#8217;100000&#8242;,&#8221;b&#8221;:&#8217;110000&#8242;,&#8221;c&#8221;:&#8217;100100&#8242;,&#8221;d&#8221;:&#8217;100110&#8242;,&#8221;e&#8221;:&#8217;100010&#8242;,&#8221;f&#8221;:&#8217;110100&#8242;,&#8221;g&#8221;:&#8217;110110&#8242;,&#8221;h&#8221;:&#8217;110010&#8242;,&#8221;i&#8221;:&#8217;010100&#8242;,&#8221;j&#8221;:&#8217;010110&#8242;,&#8221;k&#8221;:&#8217;101000&#8242;,&#8221;l&#8221;:&#8217;111000&#8242;,&#8221;m&#8221;:&#8217;101100&#8242;,&#8221;n&#8221;:&#8217;101110&#8242;,&#8221;o&#8221;:&#8217;101010&#8242;,&#8221;p&#8221;:&#8217;111100&#8242;,&#8221;q&#8221;:&#8217;111110&#8242;,&#8221;r&#8221;:&#8217;111010&#8242;,&#8221;s&#8221;:&#8217;011100&#8242;,&#8221;t&#8221;:&#8217;011110&#8242;,&#8221;u&#8221;:&#8217;101001&#8242;,&#8221;v&#8221;:&#8217;111001&#8242;,&#8221;w&#8221;:&#8217;010111&#8242;,&#8221;x&#8221;:&#8217;010111&#8242;,&#8221;y&#8221;:&#8217;101011&#8242;,&#8221;z&#8221;:&#8217;101011&#8242;} inputList = plaintext.split(&#8216;,&#8217;) for word in inputList: print words[word] text = &#8220;j,o,s,e&#8221; answer(text) You had a bunch of typos in your dict, pay attention to the traceback, it tells you exactly what&#8217;s wrong. You also never actually called the function you defined. You &#8230; <a title=\"[Solved] What is wrong with my translator? (Python) [closed]\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/\" aria-label=\"More on [Solved] What is wrong with my translator? (Python) [closed]\">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":[349,382],"class_list":["post-31546","post","type-post","status-publish","format-standard","hentry","category-solved","tag-python","tag-syntax-error"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[Solved] What is wrong with my translator? (Python) [closed] - 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-what-is-wrong-with-my-translator-python-closed\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] What is wrong with my translator? (Python) [closed] - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] I assume you want something like: def answer(plaintext): words = {&quot;a&quot;:&#039;100000&#039;,&quot;b&quot;:&#039;110000&#039;,&quot;c&quot;:&#039;100100&#039;,&quot;d&quot;:&#039;100110&#039;,&quot;e&quot;:&#039;100010&#039;,&quot;f&quot;:&#039;110100&#039;,&quot;g&quot;:&#039;110110&#039;,&quot;h&quot;:&#039;110010&#039;,&quot;i&quot;:&#039;010100&#039;,&quot;j&quot;:&#039;010110&#039;,&quot;k&quot;:&#039;101000&#039;,&quot;l&quot;:&#039;111000&#039;,&quot;m&quot;:&#039;101100&#039;,&quot;n&quot;:&#039;101110&#039;,&quot;o&quot;:&#039;101010&#039;,&quot;p&quot;:&#039;111100&#039;,&quot;q&quot;:&#039;111110&#039;,&quot;r&quot;:&#039;111010&#039;,&quot;s&quot;:&#039;011100&#039;,&quot;t&quot;:&#039;011110&#039;,&quot;u&quot;:&#039;101001&#039;,&quot;v&quot;:&#039;111001&#039;,&quot;w&quot;:&#039;010111&#039;,&quot;x&quot;:&#039;010111&#039;,&quot;y&quot;:&#039;101011&#039;,&quot;z&quot;:&#039;101011&#039;} inputList = plaintext.split(&#039;,&#039;) for word in inputList: print words[word] text = &quot;j,o,s,e&quot; answer(text) You had a bunch of typos in your dict, pay attention to the traceback, it tells you exactly what&#8217;s wrong. You also never actually called the function you defined. You ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-22T05:14:03+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=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-what-is-wrong-with-my-translator-python-closed\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-what-is-wrong-with-my-translator-python-closed\\\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/person\\\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] What is wrong with my translator? (Python) [closed]\",\"datePublished\":\"2023-01-22T05:14:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-what-is-wrong-with-my-translator-python-closed\\\/\"},\"wordCount\":65,\"publisher\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\"},\"keywords\":[\"python\",\"syntax-error\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-what-is-wrong-with-my-translator-python-closed\\\/\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-what-is-wrong-with-my-translator-python-closed\\\/\",\"name\":\"[Solved] What is wrong with my translator? (Python) [closed] - JassWeb\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#website\"},\"datePublished\":\"2023-01-22T05:14:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-what-is-wrong-with-my-translator-python-closed\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-what-is-wrong-with-my-translator-python-closed\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-what-is-wrong-with-my-translator-python-closed\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] What is wrong with my translator? (Python) [closed]\"}]},{\"@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=1777613206\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206\",\"contentUrl\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\\\/\\\/jassweb.com\"],\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/author\\\/jaspritsinghghumangmail-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] What is wrong with my translator? (Python) [closed] - 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-what-is-wrong-with-my-translator-python-closed\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] What is wrong with my translator? (Python) [closed] - JassWeb","og_description":"[ad_1] I assume you want something like: def answer(plaintext): words = {\"a\":'100000',\"b\":'110000',\"c\":'100100',\"d\":'100110',\"e\":'100010',\"f\":'110100',\"g\":'110110',\"h\":'110010',\"i\":'010100',\"j\":'010110',\"k\":'101000',\"l\":'111000',\"m\":'101100',\"n\":'101110',\"o\":'101010',\"p\":'111100',\"q\":'111110',\"r\":'111010',\"s\":'011100',\"t\":'011110',\"u\":'101001',\"v\":'111001',\"w\":'010111',\"x\":'010111',\"y\":'101011',\"z\":'101011'} inputList = plaintext.split(',') for word in inputList: print words[word] text = \"j,o,s,e\" answer(text) You had a bunch of typos in your dict, pay attention to the traceback, it tells you exactly what&#8217;s wrong. You also never actually called the function you defined. You ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/","og_site_name":"JassWeb","article_published_time":"2023-01-22T05:14:03+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] What is wrong with my translator? (Python) [closed]","datePublished":"2023-01-22T05:14:03+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/"},"wordCount":65,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["python","syntax-error"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/","url":"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/","name":"[Solved] What is wrong with my translator? (Python) [closed] - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2023-01-22T05:14:03+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-what-is-wrong-with-my-translator-python-closed\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] What is wrong with my translator? (Python) [closed]"}]},{"@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=1777613206","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206","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\/31546","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=31546"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/31546\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=31546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=31546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=31546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}