{"id":1512,"date":"2025-09-28T16:24:13","date_gmt":"2025-09-28T09:24:13","guid":{"rendered":"https:\/\/kienthucmo.com\/?p=1512"},"modified":"2025-11-05T23:38:48","modified_gmt":"2025-11-05T16:38:48","slug":"xoa-phan-tu-trong-list-bang-python","status":"publish","type":"post","link":"https:\/\/kienthucmo.com\/vi\/xoa-phan-tu-trong-list-bang-python\/","title":{"rendered":"X\u00f3a ph\u1ea7n t\u1eed trong List b\u1eb1ng Python"},"content":{"rendered":"\n<p>Khi l\u1eadp tr\u00ecnh v\u1edbi Python, <strong>list<\/strong> l\u00e0 m\u1ed9t trong nh\u1eefng ki\u1ec3u d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c m\u00ecnh s\u1eed d\u1ee5ng nhi\u1ec1u nh\u1ea5t. List \u0111\u00f3ng vai tr\u00f2 nh\u01b0 m\u1ed9t \u201cchi\u1ebfc h\u1ed9p\u201d linh ho\u1ea1t, c\u00f3 th\u1ec3 ch\u1ee9a nhi\u1ec1u lo\u1ea1i d\u1eef li\u1ec7u kh\u00e1c nhau, t\u1eeb s\u1ed1 nguy\u00ean, chu\u1ed7i, cho \u0111\u1ebfn c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng ph\u1ee9c t\u1ea1p. M\u1ed9t trong nh\u1eefng thao t\u00e1c m\u00ecnh hay g\u1eb7p nh\u1ea5t ch\u00ednh l\u00e0 <strong>x\u00f3a ph\u1ea7n t\u1eed kh\u1ecfi list<\/strong>.<\/p>\n\n\n\n<p>Nghe c\u00f3 v\u1ebb \u0111\u01a1n gi\u1ea3n, nh\u01b0ng th\u1ef1c t\u1ebf Python cung c\u1ea5p kh\u00e1 nhi\u1ec1u c\u00e1ch \u0111\u1ec3 th\u1ef1c hi\u1ec7n, m\u1ed7i c\u00e1ch l\u1ea1i c\u00f3 \u01b0u \u2013 nh\u01b0\u1ee3c \u0111i\u1ec3m v\u00e0 t\u00ecnh hu\u1ed1ng s\u1eed d\u1ee5ng kh\u00e1c nhau. Trong b\u00e0i vi\u1ebft n\u00e0y, m\u00ecnh s\u1ebd h\u1ec7 th\u1ed1ng l\u1ea1i c\u00e1c ph\u01b0\u01a1ng ph\u00e1p, t\u1eeb c\u01a1 b\u1ea3n \u0111\u1ebfn n\u00e2ng cao, \u0111\u1ec3 x\u00f3a ph\u1ea7n t\u1eed trong list hi\u1ec7u qu\u1ea3.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. T\u1ea1i sao c\u1ea7n x\u00f3a ph\u1ea7n t\u1eed trong List?<\/h2>\n\n\n\n<p>Trong th\u1ef1c t\u1ebf, m\u00ecnh th\u01b0\u1eddng x\u00f3a ph\u1ea7n t\u1eed kh\u1ecfi list v\u00ec nh\u1eefng l\u00fd do sau:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Lo\u1ea1i b\u1ecf d\u1eef li\u1ec7u kh\u00f4ng mong mu\u1ed1n:<\/strong> V\u00ed d\u1ee5 nh\u01b0 danh s\u00e1ch \u0111i\u1ec3m s\u1ed1 c\u00f3 ph\u1ea7n t\u1eed \u00e2m.<\/li>\n\n\n\n<li><strong>C\u1eadp nh\u1eadt d\u1eef li\u1ec7u \u0111\u1ed9ng:<\/strong> Khi l\u00e0m vi\u1ec7c v\u1edbi danh s\u00e1ch ng\u01b0\u1eddi d\u00f9ng, s\u1ea3n ph\u1ea9m, log\u2026 th\u00ec vi\u1ec7c th\u00eam \u2013 x\u00f3a l\u00e0 chuy\u1ec7n th\u01b0\u1eddng xuy\u00ean.<\/li>\n\n\n\n<li><strong>Gi\u1eef list g\u1ecdn nh\u1eb9:<\/strong> Tr\u00e1nh l\u01b0u tr\u1eef d\u1eef li\u1ec7u d\u01b0 th\u1eeba, gi\u00fap ti\u1ebft ki\u1ec7m b\u1ed9 nh\u1edb.<\/li>\n\n\n\n<li><strong>X\u1eed l\u00fd \u0111i\u1ec1u ki\u1ec7n l\u1ecdc:<\/strong> Lo\u1ea1i b\u1ecf nh\u1eefng ph\u1ea7n t\u1eed kh\u00f4ng th\u1ecfa m\u00e3n y\u00eau c\u1ea7u.<\/li>\n<\/ul>\n\n\n\n<p>Vi\u1ec7c n\u1eafm ch\u1eafc c\u00e1c ph\u01b0\u01a1ng ph\u00e1p x\u00f3a gi\u00fap m\u00ecnh ch\u1ee7 \u0111\u1ed9ng x\u1eed l\u00fd m\u1ecdi t\u00ecnh hu\u1ed1ng li\u00ean quan \u0111\u1ebfn d\u1eef li\u1ec7u.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. D\u00f9ng <code>del<\/code> \u0111\u1ec3 x\u00f3a ph\u1ea7n t\u1eed theo index<\/h2>\n\n\n\n<p>C\u00e1ch c\u01a1 b\u1ea3n nh\u1ea5t l\u00e0 s\u1eed d\u1ee5ng <strong>t\u1eeb kh\u00f3a <code>del<\/code><\/strong> \u0111\u1ec3 x\u00f3a ph\u1ea7n t\u1eed t\u1ea1i v\u1ecb tr\u00ed nh\u1ea5t \u0111\u1ecbnh.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">C\u00fa ph\u00e1p:<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>del list_name&#91;index&#93;&lt;br><\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">del<\/span><span style=\"color: #D8DEE9FF\"> list_name<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #D8DEE9FF\">index<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><span style=\"color: #81A1C1\">&lt;<\/span><span style=\"color: #D8DEE9FF\">br<\/span><span style=\"color: #81A1C1\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">V\u00ed d\u1ee5:<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># Create a list\ncolors = &#91;\"red\", \"green\", \"blue\", \"yellow\"&#93;\n\n# Delete element at index 1\ndel colors&#91;1&#93;\n\nprint(colors)  # &#91;\"red\", \"blue\", \"yellow\"&#93;\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># Create a list<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">colors <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">red<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">green<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">blue<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">yellow<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># Delete element at index 1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">del<\/span><span style=\"color: #D8DEE9FF\"> colors<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">colors<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># &#91;&quot;red&quot;, &quot;blue&quot;, &quot;yellow&quot;&#93;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Ph\u00e2n t\u00edch:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u01afu \u0111i\u1ec3m:<\/strong> \u0110\u01a1n gi\u1ea3n, nhanh g\u1ecdn khi bi\u1ebft ch\u00ednh x\u00e1c v\u1ecb tr\u00ed.<\/li>\n\n\n\n<li><strong>Nh\u01b0\u1ee3c \u0111i\u1ec3m:<\/strong> N\u1ebfu index sai \u2192 b\u00e1o l\u1ed7i <code>IndexError<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3. D\u00f9ng <code>remove()<\/code> \u0111\u1ec3 x\u00f3a theo gi\u00e1 tr\u1ecb<\/h2>\n\n\n\n<p>Khi m\u00ecnh bi\u1ebft gi\u00e1 tr\u1ecb ph\u1ea7n t\u1eed c\u1ea7n x\u00f3a, <code>remove()<\/code> l\u00e0 l\u1ef1a ch\u1ecdn ph\u00f9 h\u1ee3p.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">C\u00fa ph\u00e1p:<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>list_name.remove(value)\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9FF\">list_name<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">remove<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">value<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">V\u00ed d\u1ee5:<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># Create a list\nanimals = &#91;\"dog\", \"cat\", \"bird\", \"cat\"&#93;\n\n# Remove the first \"cat\"\nanimals.remove(\"cat\")\n\nprint(animals)  # &#91;\"dog\", \"bird\", \"cat\"&#93;\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># Create a list<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">animals <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">dog<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">cat<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">bird<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">cat<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># Remove the first &quot;cat&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">animals<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">remove<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">cat<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">animals<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># &#91;&quot;dog&quot;, &quot;bird&quot;, &quot;cat&quot;&#93;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Ph\u00e2n t\u00edch:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u01afu \u0111i\u1ec3m:<\/strong> D\u1ec5 d\u00f9ng, tr\u1ef1c quan.<\/li>\n\n\n\n<li><strong>Nh\u01b0\u1ee3c \u0111i\u1ec3m:<\/strong> Ch\u1ec9 x\u00f3a <strong>l\u1ea7n xu\u1ea5t hi\u1ec7n \u0111\u1ea7u ti\u00ean<\/strong>, n\u1ebfu kh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb s\u1ebd b\u00e1o <code>ValueError<\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">4. D\u00f9ng <code>pop()<\/code> \u0111\u1ec3 x\u00f3a v\u00e0 l\u1ea5y gi\u00e1 tr\u1ecb<\/h2>\n\n\n\n<p>Ph\u01b0\u01a1ng th\u1ee9c <code>pop()<\/code> v\u1eeba x\u00f3a v\u1eeba tr\u1ea3 v\u1ec1 ph\u1ea7n t\u1eed. N\u1ebfu kh\u00f4ng truy\u1ec1n index, n\u00f3 m\u1eb7c \u0111\u1ecbnh x\u00f3a ph\u1ea7n t\u1eed cu\u1ed1i.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">C\u00fa ph\u00e1p:<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>list_name.pop(index)   # index t\u00f9y ch\u1ecdn\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9FF\">list_name<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">pop<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">index<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #616E88\"># index t\u00f9y ch\u1ecdn<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">V\u00ed d\u1ee5:<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># Create a list\nletters = &#91;\"a\", \"b\", \"c\", \"d\"&#93;\n\n# Pop element at index 2\nremoved = letters.pop(2)\n\nprint(letters)   # &#91;\"a\", \"b\", \"d\"&#93;\nprint(removed)   # c\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># Create a list<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">letters <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">a<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">b<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">c<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">d<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># Pop element at index 2<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">removed <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> letters<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">pop<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #B48EAD\">2<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">letters<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #616E88\"># &#91;&quot;a&quot;, &quot;b&quot;, &quot;d&quot;&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">removed<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #616E88\"># c<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Ph\u00e2n t\u00edch:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u01afu \u0111i\u1ec3m:<\/strong> L\u1ea5y \u0111\u01b0\u1ee3c ph\u1ea7n t\u1eed v\u1eeba x\u00f3a.<\/li>\n\n\n\n<li><strong>Nh\u01b0\u1ee3c \u0111i\u1ec3m:<\/strong> Index kh\u00f4ng t\u1ed3n t\u1ea1i \u2192 b\u00e1o l\u1ed7i.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">5. X\u00f3a to\u00e0n b\u1ed9 list b\u1eb1ng <code>clear()<\/code><\/h2>\n\n\n\n<p>N\u1ebfu c\u1ea7n l\u00e0m r\u1ed7ng list, m\u00ecnh c\u00f3 th\u1ec3 d\u00f9ng <code>clear()<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">V\u00ed d\u1ee5:<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># Create a list\nnumbers = &#91;1, 2, 3, 4, 5&#93;\n\n# Clear all elements\nnumbers.clear()\n\nprint(numbers)   # []\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># Create a list<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">numbers <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">2<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">3<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">4<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">5<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># Clear all elements<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">numbers<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">clear<\/span><span style=\"color: #ECEFF4\">()<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">numbers<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #616E88\"># []<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Ph\u00e2n t\u00edch:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>C\u00e1ch nhanh nh\u1ea5t \u0111\u1ec3 x\u00f3a h\u1ebft ph\u1ea7n t\u1eed.<\/li>\n\n\n\n<li>Kh\u00f4ng linh ho\u1ea1t v\u00ec kh\u00f4ng ch\u1ecdn l\u1ecdc ph\u1ea7n t\u1eed.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">6. X\u00f3a ph\u1ea7n t\u1eed theo \u0111i\u1ec1u ki\u1ec7n v\u1edbi List Comprehension<\/h2>\n\n\n\n<p>Khi mu\u1ed1n lo\u1ea1i b\u1ecf nhi\u1ec1u ph\u1ea7n t\u1eed c\u00f9ng l\u00fac d\u1ef1a tr\u00ean \u0111i\u1ec1u ki\u1ec7n, list comprehension l\u00e0 c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">V\u00ed d\u1ee5:<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># Create a list\nages = &#91;12, 18, 25, 30, 15, 40&#93;\n\n# Keep only ages >= 18\nages = &#91;age for age in ages if age >= 18&#93;\n\nprint(ages)  # &#91;18, 25, 30, 40&#93;\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># Create a list<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">ages <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #B48EAD\">12<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">18<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">25<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">30<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">15<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">40<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># Keep only ages &gt;= 18<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">ages <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #D8DEE9FF\">age <\/span><span style=\"color: #81A1C1\">for<\/span><span style=\"color: #D8DEE9FF\"> age <\/span><span style=\"color: #81A1C1\">in<\/span><span style=\"color: #D8DEE9FF\"> ages <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> age <\/span><span style=\"color: #81A1C1\">&gt;=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">18<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">ages<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># &#91;18, 25, 30, 40&#93;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Ph\u00e2n t\u00edch:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u01afu \u0111i\u1ec3m:<\/strong> R\u1ea5t linh ho\u1ea1t, c\u00f3 th\u1ec3 l\u1ecdc theo \u0111i\u1ec1u ki\u1ec7n.<\/li>\n\n\n\n<li><strong>Nh\u01b0\u1ee3c \u0111i\u1ec3m:<\/strong> T\u1ea1o list m\u1edbi thay v\u00ec ch\u1ec9nh s\u1eeda tr\u1ef1c ti\u1ebfp.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">7. So s\u00e1nh c\u00e1c ph\u01b0\u01a1ng ph\u00e1p<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Ph\u01b0\u01a1ng ph\u00e1p<\/th><th>X\u00f3a theo g\u00ec?<\/th><th>Tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb?<\/th><th>\u01afu \u0111i\u1ec3m<\/th><th>Nh\u01b0\u1ee3c \u0111i\u1ec3m<\/th><\/tr><\/thead><tbody><tr><td><code>del<\/code><\/td><td>Index<\/td><td>Kh\u00f4ng<\/td><td>Nhanh, tr\u1ef1c quan<\/td><td>B\u00e1o l\u1ed7i n\u1ebfu index sai<\/td><\/tr><tr><td><code>remove()<\/code><\/td><td>Gi\u00e1 tr\u1ecb<\/td><td>Kh\u00f4ng<\/td><td>D\u1ec5 hi\u1ec3u, tr\u1ef1c quan<\/td><td>Ch\u1ec9 x\u00f3a l\u1ea7n \u0111\u1ea7u, b\u00e1o l\u1ed7i n\u1ebfu kh\u00f4ng t\u00ecm th\u1ea5y<\/td><\/tr><tr><td><code>pop()<\/code><\/td><td>Index (ho\u1eb7c cu\u1ed1i)<\/td><td>C\u00f3<\/td><td>V\u1eeba x\u00f3a v\u1eeba tr\u1ea3 gi\u00e1 tr\u1ecb<\/td><td>B\u00e1o l\u1ed7i n\u1ebfu index sai<\/td><\/tr><tr><td><code>clear()<\/code><\/td><td>To\u00e0n b\u1ed9 list<\/td><td>Kh\u00f4ng<\/td><td>R\u00f5 r\u00e0ng, nhanh g\u1ecdn<\/td><td>Kh\u00f4ng ch\u1ecdn l\u1ecdc<\/td><\/tr><tr><td>List comprehension<\/td><td>\u0110i\u1ec1u ki\u1ec7n l\u1ecdc<\/td><td>Kh\u00f4ng<\/td><td>Linh ho\u1ea1t, g\u1ecdn g\u00e0ng<\/td><td>T\u1ea1o list m\u1edbi<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">8. \u1ee8ng d\u1ee5ng th\u1ef1c t\u1ebf<\/h2>\n\n\n\n<p>M\u1ed9t v\u00e0i t\u00ecnh hu\u1ed1ng th\u1ef1c t\u1ebf m\u00ecnh \u0111\u00e3 g\u1eb7p:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>X\u1eed l\u00fd d\u1eef li\u1ec7u \u0111\u1ea7u v\u00e0o:<\/strong> X\u00f3a d\u1eef li\u1ec7u null ho\u1eb7c kh\u00f4ng h\u1ee3p l\u1ec7 trong danh s\u00e1ch \u0111\u1ecdc t\u1eeb file CSV.<\/li>\n\n\n\n<li><strong>Qu\u1ea3n l\u00fd ng\u01b0\u1eddi d\u00f9ng:<\/strong> X\u00f3a user b\u1ecb kh\u00f3a kh\u1ecfi danh s\u00e1ch \u0111ang \u0111\u0103ng nh\u1eadp.<\/li>\n\n\n\n<li><strong>L\u1ecdc d\u1eef li\u1ec7u \u0111\u1ed9ng:<\/strong> Lo\u1ea1i b\u1ecf s\u1ea3n ph\u1ea9m c\u00f3 gi\u00e1 th\u1ea5p h\u01a1n m\u1ee9c t\u1ed1i thi\u1ec3u trong gi\u1ecf h\u00e0ng.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">9. K\u1ebft lu\u1eadn<\/h2>\n\n\n\n<p>B\u00e0i vi\u1ebft \u0111\u00e3 tr\u00ecnh b\u00e0y chi ti\u1ebft c\u00e1c c\u00e1ch x\u00f3a ph\u1ea7n t\u1eed trong <strong>list Python<\/strong>, g\u1ed3m: <code>del<\/code>, <code>remove()<\/code>, <code>pop()<\/code>, <code>clear()<\/code> v\u00e0 list comprehension. M\u1ed7i ph\u01b0\u01a1ng ph\u00e1p c\u00f3 \u01b0u nh\u01b0\u1ee3c \u0111i\u1ec3m ri\u00eang, v\u00e0 vi\u1ec7c l\u1ef1a ch\u1ecdn ph\u1ee5 thu\u1ed9c v\u00e0o t\u00ecnh hu\u1ed1ng c\u1ee5 th\u1ec3.<\/p>\n\n\n\n<p>Th\u00e0nh th\u1ea1o nh\u1eefng thao t\u00e1c n\u00e0y gi\u00fap m\u00ecnh x\u1eed l\u00fd d\u1eef li\u1ec7u linh ho\u1ea1t v\u00e0 vi\u1ebft code g\u1ecdn g\u00e0ng, hi\u1ec7u qu\u1ea3 h\u01a1n.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">10. T\u00e0i li\u1ec7u tham kh\u1ea3o<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Python Software Foundation. (2024). <em>Python Documentation: Lists<\/em>. Retrieved from <a>https:\/\/docs.python.org\/3\/tutorial\/datastructures.html<\/a><\/li>\n\n\n\n<li>Lutz, M. (2013). <em>Learning Python (5th Edition)<\/em>. O\u2019Reilly Media.<\/li>\n\n\n\n<li>Python for Professionals: Learning Python as a Second Language: <a href=\"https:\/\/click.linksynergy.com\/link?id=*C\/UgjGtUZ8&amp;offerid=1562891.3721710002222624882405978&amp;type=15&amp;murl=https%3A%2F%2Fwww.kobo.com%2Fus%2Fen%2Febook%2Fpython-for-professionals-3\" target=\"_blank\" rel=\"noopener\">https:\/\/www.kobo.com\/us\/en\/ebook\/python-for-professionals-3<\/a><\/li>\n\n\n\n<li>Python: Deeper Insights into Machine Learning: <a href=\"https:\/\/click.linksynergy.com\/link?id=*C\/UgjGtUZ8&amp;offerid=1562891.3721710015810095319857183&amp;type=15&amp;murl=https%3A%2F%2Fwww.kobo.com%2Fus%2Fen%2Febook%2Fpython-deeper-insights-into-machine-learning\" target=\"_blank\" rel=\"noopener\">https:\/\/www.kobo.com\/us\/en\/ebook\/python-deeper-insights-into-machine-learning<\/a><\/li>\n\n\n\n<li>DataFusion Python Bindings in Practice: The Complete Guide for Developers and Engineers: <a href=\"https:\/\/click.linksynergy.com\/link?id=*C\/UgjGtUZ8&amp;offerid=1562891.3721710049093362364820452&amp;type=15&amp;murl=https%3A%2F%2Fwww.kobo.com%2Fus%2Fen%2Febook%2Fdatafusion-python-bindings-in-practice\" target=\"_blank\" rel=\"noopener\">https:\/\/www.kobo.com\/us\/en\/ebook\/datafusion-python-bindings-in-practice<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Khi l\u1eadp tr\u00ecnh v\u1edbi Python, list l\u00e0 m\u1ed9t trong nh\u1eefng ki\u1ec3u d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c m\u00ecnh s\u1eed d\u1ee5ng nhi\u1ec1u nh\u1ea5t. List \u0111\u00f3ng vai tr\u00f2 nh\u01b0 m\u1ed9t \u201cchi\u1ebfc h\u1ed9p\u201d linh ho\u1ea1t, c\u00f3 th\u1ec3 ch\u1ee9a nhi\u1ec1u lo\u1ea1i d\u1eef li\u1ec7u kh\u00e1c nhau, t\u1eeb s\u1ed1 nguy\u00ean, chu\u1ed7i, cho \u0111\u1ebfn c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng ph\u1ee9c t\u1ea1p. M\u1ed9t trong nh\u1eefng thao t\u00e1c m\u00ecnh hay g\u1eb7p nh\u1ea5t ch\u00ednh l\u00e0 x\u00f3a ph\u1ea7n t\u1eed kh\u1ecfi list.<\/p>\n","protected":false},"author":1,"featured_media":1748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"googlesitekit_rrm_CAowieHDDA:productID":"","footnotes":""},"categories":[41],"tags":[40],"class_list":["post-1512","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kien-thuc-lap-trinh","tag-python-co-ban"],"_links":{"self":[{"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/posts\/1512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/comments?post=1512"}],"version-history":[{"count":3,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/posts\/1512\/revisions"}],"predecessor-version":[{"id":2448,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/posts\/1512\/revisions\/2448"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/media\/1748"}],"wp:attachment":[{"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/media?parent=1512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/categories?post=1512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/tags?post=1512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}