{"id":8697,"date":"2021-09-05T19:02:38","date_gmt":"2021-09-05T16:02:38","guid":{"rendered":"https:\/\/elzero.org\/?p=8697"},"modified":"2022-08-07T06:47:27","modified_gmt":"2022-08-07T03:47:27","slug":"python-problems-solving-number-to-reversed-list","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/python-problems-solving-number-to-reversed-list\/","title":{"rendered":"Number To Reversed List"},"content":{"rendered":"<h3>\u0627\u0644\u062d\u0644 01<\/h3>\r\n\r\n<script type=\"text\/plain\" class=\"language-python\">\r\ndef convert(n):\r\n  # Convert To String\r\n  st = str(n)\r\n  # Create Empty List\r\n  result = []\r\n  # Loop On String Contains The Numbers\r\n  for num in st:\r\n    # Append Every Number To Empty List\r\n    result.append(int(num))\r\n  # Reverse The List\r\n  result.reverse()\r\n  return result\r\n\r\nprint(convert(564987654)) # [4, 5, 6, 7, 8, 9, 4, 6, 5]\r\nprint(convert(529132)) # [2, 3, 1, 9, 2, 5]\r\n<\/script>\r\n\r\n<hr class=\"separator\">\r\n\r\n<h3>\u0627\u0644\u062d\u0644 02<\/h3>\r\n\r\n<script type=\"text\/plain\" class=\"language-python\">\r\ndef convert(n):\r\n  # Create Empty List\r\n  result = []\r\n  # Loop On String Contains The Numbers\r\n  for num in str(n):\r\n    # Append Every Number To Empty List At Position 0\r\n    result.insert(0, int(num))\r\n  return result\r\n\r\nprint(convert(564987654)) # [4, 5, 6, 7, 8, 9, 4, 6, 5]\r\nprint(convert(529132)) # [2, 3, 1, 9, 2, 5]\r\n<\/script>\r\n\r\n<hr class=\"separator\">\r\n\r\n<h3>\u0627\u0644\u062d\u0644 03<\/h3>\r\n\r\n<script type=\"text\/plain\" class=\"language-python\">\r\ndef convert(n):\r\n  return [int(num) for num in str(n)[::-1]]\r\n\r\n# int(num) => Make num Integer\r\n# str(n) => Convert n To String\r\n# [::-1] => Slicing Backwards\r\n\r\nprint(convert(564987654)) # [4, 5, 6, 7, 8, 9, 4, 6, 5]\r\nprint(convert(529132)) # [2, 3, 1, 9, 2, 5]\r\n<\/script>","protected":false},"excerpt":{"rendered":"<p>\u0627\u0644\u062d\u0644 01 \u0627\u0644\u062d\u0644 02 \u0627\u0644\u062d\u0644 03<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1337],"tags":[],"class_list":["post-8697","post","type-post","status-publish","format-standard","hentry","category-problems-solving"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=8697"}],"version-history":[{"count":1,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8697\/revisions"}],"predecessor-version":[{"id":8698,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8697\/revisions\/8698"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=8697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=8697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=8697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}