{"id":13990,"date":"2023-12-04T20:20:22","date_gmt":"2023-12-04T11:20:22","guid":{"rendered":"http:\/\/www.tyosuke20xx.com\/blog\/?p=13990"},"modified":"2023-12-04T20:20:24","modified_gmt":"2023-12-04T11:20:24","slug":"python-todo%e3%83%aa%e3%82%b9%e3%83%88","status":"publish","type":"post","link":"http:\/\/www.tyosuke20xx.com\/blog\/?p=13990","title":{"rendered":"Python Todo\u30ea\u30b9\u30c8"},"content":{"rendered":"\n<p>class TodoList:<br>def <strong>init<\/strong>(self):<br>self.tasks = []<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def add_task(self, task):\n    self.tasks.append(task)\n\ndef remove_task(self, task):\n    if task in self.tasks:\n        self.tasks.remove(task)\n    else:\n        print(\"\u30bf\u30b9\u30af\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002\")\n\ndef list_tasks(self):\n    if not self.tasks:\n        print(\"ToDo\u30ea\u30b9\u30c8\u306f\u7a7a\u3067\u3059\u3002\")\n    else:\n        print(\"ToDo\u30ea\u30b9\u30c8:\")\n        for idx, task in enumerate(self.tasks, start=1):\n            print(f\"{idx}. {task}\")<\/code><\/pre>\n\n\n\n<p>def main():<br>todo_list = TodoList()<br>while True:<br>print(&#8220;\\n\u64cd\u4f5c\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044:&#8221;)<br>print(&#8220;1. \u30bf\u30b9\u30af\u3092\u8ffd\u52a0&#8221;)<br>print(&#8220;2. \u30bf\u30b9\u30af\u3092\u524a\u9664&#8221;)<br>print(&#8220;3. \u30bf\u30b9\u30af\u4e00\u89a7\u3092\u8868\u793a&#8221;)<br>print(&#8220;4. \u7d42\u4e86&#8221;)<br>choice = input(&#8220;\u9078\u629e: &#8220;)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    if choice == '1':\n        task = input(\"\u30bf\u30b9\u30af\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044: \")\n        todo_list.add_task(task)\n        print(\"\u30bf\u30b9\u30af\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002\")\n\n    elif choice == '2':\n        task_idx = int(input(\"\u524a\u9664\u3059\u308b\u30bf\u30b9\u30af\u306e\u756a\u53f7\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044: \"))\n        if 1 &lt;= task_idx &lt;= len(todo_list.tasks):\n            task_to_remove = todo_list.tasks&#91;task_idx - 1]\n            todo_list.remove_task(task_to_remove)\n            print(\"\u30bf\u30b9\u30af\u304c\u524a\u9664\u3055\u308c\u307e\u3057\u305f\u3002\")\n        else:\n            print(\"\u7121\u52b9\u306a\u756a\u53f7\u3067\u3059\u3002\")\n\n    elif choice == '3':\n        todo_list.list_tasks()\n\n    elif choice == '4':\n        print(\"\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u7d42\u4e86\u3057\u307e\u3059\u3002\")\n        break\n\n    else:\n        print(\"\u7121\u52b9\u306a\u9078\u629e\u3067\u3059\u3002\")<\/code><\/pre>\n\n\n\n<p>if <strong>name<\/strong> == &#8220;<strong>main<\/strong>&#8220;:<br>main()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>class TodoList:def init(self):self.tasks = [] def main():todo_list = TodoList()while True:print(&#8220;\\n\u64cd\u4f5c\u3092\u9078\u629e &hellip; <a href=\"http:\/\/www.tyosuke20xx.com\/blog\/?p=13990\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Python Todo\u30ea\u30b9\u30c8&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[4,65],"tags":[3,39],"class_list":["post-13990","post","type-post","status-publish","format-standard","hentry","category-programming","category-python","tag-programming","tag-python"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13990"}],"version-history":[{"count":1,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13990\/revisions"}],"predecessor-version":[{"id":13991,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13990\/revisions\/13991"}],"wp:attachment":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13990"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}