{"id":1497,"date":"2025-09-28T10:11:27","date_gmt":"2025-09-28T03:11:27","guid":{"rendered":"https:\/\/kienthucmo.com\/?p=1497"},"modified":"2025-11-05T23:35:18","modified_gmt":"2025-11-05T16:35:18","slug":"xoa-phan-tu-trong-array-voi-python","status":"publish","type":"post","link":"https:\/\/kienthucmo.com\/vi\/xoa-phan-tu-trong-array-voi-python\/","title":{"rendered":"X\u00f3a ph\u1ea7n t\u1eed trong Array v\u1edbi Python"},"content":{"rendered":"\n<p>Trong qu\u00e1 tr\u00ecnh l\u1eadp tr\u00ecnh v\u1edbi Python, m\u00ecnh th\u01b0\u1eddng xuy\u00ean ph\u1ea3i thao t\u00e1c v\u1edbi <strong>Array (m\u1ea3ng)<\/strong> ho\u1eb7c <strong>list<\/strong>. M\u1ed9t trong nh\u1eefng thao t\u00e1c quan tr\u1ecdng nh\u1ea5t l\u00e0 <strong>x\u00f3a ph\u1ea7n t\u1eed kh\u1ecfi m\u1ea3ng<\/strong>. \u0110\u00e2y kh\u00f4ng ch\u1ec9 l\u00e0 ki\u1ebfn th\u1ee9c c\u01a1 b\u1ea3n m\u00e0 c\u00f2n \u1ea3nh h\u01b0\u1edfng tr\u1ef1c ti\u1ebfp \u0111\u1ebfn hi\u1ec7u qu\u1ea3 x\u1eed l\u00fd d\u1eef li\u1ec7u, \u0111\u1eb7c bi\u1ec7t trong c\u00e1c b\u00e0i to\u00e1n y\u00eau c\u1ea7u t\u1ed1i \u01b0u v\u1ec1 b\u1ed9 nh\u1edb ho\u1eb7c t\u1ed1c \u0111\u1ed9.<\/p>\n\n\n\n<p>\u1ede b\u00e0i vi\u1ebft n\u00e0y, m\u00ecnh s\u1ebd chia s\u1ebb chi ti\u1ebft v\u1ec1 c\u00e1c c\u00e1ch x\u00f3a ph\u1ea7n t\u1eed trong m\u1ea3ng (list) \u1edf Python, k\u00e8m theo v\u00ed d\u1ee5 minh h\u1ecda, ph\u00e2n t\u00edch \u01b0u nh\u01b0\u1ee3c \u0111i\u1ec3m v\u00e0 t\u00ecnh hu\u1ed1ng \u00e1p d\u1ee5ng th\u1ef1c t\u1ebf.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. T\u1ea1i sao c\u1ea7n x\u00f3a ph\u1ea7n t\u1eed trong Array?<\/h2>\n\n\n\n<p>Khi l\u00e0m vi\u1ec7c v\u1edbi d\u1eef li\u1ec7u, c\u00f3 nhi\u1ec1u t\u00ecnh hu\u1ed1ng khi\u1ebfn m\u00ecnh ph\u1ea3i x\u00f3a ph\u1ea7n t\u1eed trong m\u1ea3ng:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Lo\u1ea1i b\u1ecf d\u1eef li\u1ec7u kh\u00f4ng h\u1ee3p l\u1ec7:<\/strong> V\u00ed d\u1ee5 m\u1ea3ng l\u01b0u tr\u1eef \u0111i\u1ec3m s\u1ed1 nh\u01b0ng c\u00f3 ph\u1ea7n t\u1eed \u00e2m.<\/li>\n\n\n\n<li><strong>T\u1ed1i \u01b0u b\u1ed9 nh\u1edb:<\/strong> X\u00f3a c\u00e1c gi\u00e1 tr\u1ecb kh\u00f4ng c\u1ea7n thi\u1ebft \u0111\u1ec3 ti\u1ebft ki\u1ec7m RAM.<\/li>\n\n\n\n<li><strong>C\u1eadp nh\u1eadt d\u1eef li\u1ec7u:<\/strong> Khi m\u1ed9t ph\u1ea7n t\u1eed kh\u00f4ng c\u00f2n \u0111\u00fang v\u1edbi y\u00eau c\u1ea7u, m\u00ecnh c\u1ea7n lo\u1ea1i b\u1ecf n\u00f3.<\/li>\n\n\n\n<li><strong>X\u1eed l\u00fd d\u1eef li\u1ec7u \u0111\u1ed9ng:<\/strong> Trong c\u00e1c \u1ee9ng d\u1ee5ng nh\u01b0 h\u1ec7 th\u1ed1ng h\u00e0ng \u0111\u1ee3i, stack, ho\u1eb7c x\u1eed l\u00fd log, vi\u1ec7c th\u00eam \u2013 x\u00f3a l\u00e0 b\u1eaft bu\u1ed9c.<\/li>\n<\/ul>\n\n\n\n<p>T\u00f3m l\u1ea1i, \u0111\u00e2y l\u00e0 m\u1ed9t thao t\u00e1c c\u1ef1c k\u1ef3 ph\u1ed5 bi\u1ebfn, m\u00ecnh ngh\u0129 b\u1ea5t k\u1ef3 l\u1eadp tr\u00ecnh vi\u00ean n\u00e0o c\u0169ng ph\u1ea3i n\u1eafm v\u1eefng.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. S\u1eed d\u1ee5ng <code>del<\/code> \u0111\u1ec3 x\u00f3a ph\u1ea7n t\u1eed<\/h2>\n\n\n\n<p>L\u1ec7nh <code>del<\/code> \u0111\u01b0\u1ee3c Python cung c\u1ea5p s\u1eb5n \u0111\u1ec3 x\u00f3a ph\u1ea7n t\u1eed t\u1ea1i m\u1ed9t v\u1ecb tr\u00ed c\u1ee5 th\u1ec3 trong m\u1ea3ng.<\/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 array&#91;index&#93;<\/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\"> array<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #D8DEE9FF\">index<\/span><span style=\"color: #ECEFF4\">&#93;<\/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\nnumbers = &#91;10, 20, 30, 40, 50&#93;\n\n# Delete the element at index 2\ndel numbers&#91;2&#93;\n\nprint(numbers)  # &#91;10, 20, 40, 50&#93;<\/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\">10<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">20<\/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\">40<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">50<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># Delete the element at index 2<\/span><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">del<\/span><span style=\"color: #D8DEE9FF\"> numbers<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #B48EAD\">2<\/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\">numbers<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># &#91;10, 20, 40, 50&#93;<\/span><\/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, tr\u1ef1c quan.<\/li>\n\n\n\n<li><strong>Nh\u01b0\u1ee3c \u0111i\u1ec3m:<\/strong> Ph\u1ea3i bi\u1ebft ch\u00ednh x\u00e1c <strong>ch\u1ec9 s\u1ed1 (index)<\/strong> c\u1ee7a ph\u1ea7n t\u1eed c\u1ea7n x\u00f3a. N\u1ebfu index kh\u00f4ng t\u1ed3n t\u1ea1i s\u1ebd g\u00e2y l\u1ed7i <code>IndexError<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3. D\u00f9ng ph\u01b0\u01a1ng th\u1ee9c <code>remove()<\/code> \u0111\u1ec3 x\u00f3a theo gi\u00e1 tr\u1ecb<\/h2>\n\n\n\n<p>N\u1ebfu mu\u1ed1n x\u00f3a m\u1ed9t ph\u1ea7n t\u1eed <strong>theo gi\u00e1 tr\u1ecb<\/strong> ch\u1ee9 kh\u00f4ng ph\u1ea3i index, m\u00ecnh c\u00f3 th\u1ec3 d\u00f9ng <code>remove()<\/code>.<\/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>array.remove(value)<\/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\">array<\/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><\/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\nfruits = &#91;\"apple\", \"banana\", \"cherry\", \"banana\"&#93;\n\n# Remove the first \"banana\"\nfruits.remove(\"banana\")\n\nprint(fruits)  # &#91;\"apple\", \"cherry\", \"banana\"&#93;<\/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\">fruits <\/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\">apple<\/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\">banana<\/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\">cherry<\/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\">banana<\/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;banana&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">fruits<\/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\">banana<\/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\">fruits<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># &#91;&quot;apple&quot;, &quot;cherry&quot;, &quot;banana&quot;&#93;<\/span><\/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 s\u1eed d\u1ee5ng khi ch\u1ec9 bi\u1ebft gi\u00e1 tr\u1ecb ph\u1ea7n t\u1eed.<\/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 ph\u1ea7n t\u1eed kh\u00f4ng t\u1ed3n t\u1ea1i s\u1ebd b\u00e1o l\u1ed7i <code>ValueError<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">4. D\u00f9ng <code>pop()<\/code> \u0111\u1ec3 v\u1eeba x\u00f3a v\u1eeba l\u1ea5y gi\u00e1 tr\u1ecb<\/h2>\n\n\n\n<p><code><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\">pop()<\/mark><\/code> gi\u00fap x\u00f3a m\u1ed9t ph\u1ea7n t\u1eed t\u1ea1i ch\u1ec9 s\u1ed1 c\u1ee5 th\u1ec3 v\u00e0 \u0111\u1ed3ng th\u1eddi tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb c\u1ee7a ph\u1ea7n t\u1eed \u0111\u00f3.<\/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>array.pop(index)   # index l\u00e0 t\u00f9y ch\u1ecdn<\/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\">array<\/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 l\u00e0 t\u00f9y ch\u1ecdn<\/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\nletters = &#91;\"a\", \"b\", \"c\", \"d\"&#93;\n\n# Pop element at index 1\nremoved = letters.pop(1)\n\nprint(letters)   # &#91;\"a\", \"c\", \"d\"&#93;\nprint(removed)   # b<\/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 1<\/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\">1<\/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;c&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\"># b<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>N\u1ebfu kh\u00f4ng truy\u1ec1n tham s\u1ed1,<mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\"> <code>pop()<\/code><\/mark> s\u1ebd x\u00f3a <strong>ph\u1ea7n t\u1eed cu\u1ed1i c\u00f9ng<\/strong>.<\/p>\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 gi\u00e1 tr\u1ecb ph\u1ea7n t\u1eed v\u1eeba x\u00f3a.<\/li>\n\n\n\n<li><strong>Nh\u01b0\u1ee3c \u0111i\u1ec3m:<\/strong> N\u1ebfu index kh\u00f4ng t\u1ed3n t\u1ea1i s\u1ebd b\u00e1o l\u1ed7i.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">5. X\u00f3a to\u00e0n b\u1ed9 Array b\u1eb1ng <code>clear()<\/code><\/h2>\n\n\n\n<p>Trong nhi\u1ec1u tr\u01b0\u1eddng h\u1ee3p m\u00ecnh kh\u00f4ng mu\u1ed1n gi\u1eef l\u1ea1i ph\u1ea7n t\u1eed n\u00e0o, khi \u0111\u00f3 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\ndata = &#91;1, 2, 3, 4&#93;\n\n# Clear all elements\ndata.clear()\n\nprint(data)   # []<\/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\">data <\/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\">&#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\">data<\/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\">data<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #616E88\"># []<\/span><\/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>Nhanh g\u1ecdn, an to\u00e0n, kh\u00f4ng b\u00e1o l\u1ed7i.<\/li>\n\n\n\n<li>Ch\u1ec9 ph\u00f9 h\u1ee3p khi c\u1ea7n x\u00f3a to\u00e0n b\u1ed9 d\u1eef li\u1ec7u.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">6. X\u00f3a b\u1eb1ng List Comprehension<\/h2>\n\n\n\n<p>Trong t\u00ecnh hu\u1ed1ng c\u1ea7n lo\u1ea1i b\u1ecf nhi\u1ec1u ph\u1ea7n t\u1eed theo \u0111i\u1ec1u ki\u1ec7n, m\u00ecnh hay d\u00f9ng <strong>list comprehension<\/strong> \u0111\u1ec3 t\u1ea1o m\u1ed9t list m\u1edbi.<\/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, 6&#93;\n\n# Remove all even numbers\nnumbers = &#91;x for x in numbers if x % 2 != 0&#93;\n\nprint(numbers)  # &#91;1, 3, 5&#93;<\/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\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">6<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># Remove all even numbers<\/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: #D8DEE9FF\">x <\/span><span style=\"color: #81A1C1\">for<\/span><span style=\"color: #D8DEE9FF\"> x <\/span><span style=\"color: #81A1C1\">in<\/span><span style=\"color: #D8DEE9FF\"> numbers <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> x <\/span><span style=\"color: #81A1C1\">%<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">2<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">!=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/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\">numbers<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># &#91;1, 3, 5&#93;<\/span><\/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> Ng\u1eafn g\u1ecdn, d\u1ec5 \u0111\u1ecdc, x\u1eed l\u00fd linh ho\u1ea1t theo \u0111i\u1ec1u ki\u1ec7n.<\/li>\n\n\n\n<li><strong>Nh\u01b0\u1ee3c \u0111i\u1ec3m:<\/strong> Th\u1ef1c ch\u1ea5t l\u00e0 t\u1ea1o list m\u1edbi, kh\u00f4ng ph\u1ea3i x\u00f3a tr\u1ef1c ti\u1ebfp tr\u00ean list c\u0169.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">7. So s\u00e1nh c\u00e1c ph\u01b0\u01a1ng ph\u00e1p x\u00f3a ph\u1ea7n t\u1eed<\/h2>\n\n\n\n<p>\u0110\u1ec3 d\u1ec5 h\u00ecnh dung, m\u00ecnh t\u1ed5ng h\u1ee3p nhanh trong b\u1ea3ng d\u01b0\u1edbi \u0111\u00e2y:<\/p>\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>\u0110\u01a1n gi\u1ea3n, nhanh<\/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 d\u00f9ng khi bi\u1ebft gi\u00e1 tr\u1ecb<\/td><td>Ch\u1ec9 x\u00f3a l\u1ea7n xu\u1ea5t hi\u1ec7n \u0111\u1ea7u ti\u00ean<\/td><\/tr><tr><td><code>pop()<\/code><\/td><td>Index (ho\u1eb7c cu\u1ed1i)<\/td><td>C\u00f3<\/td><td>L\u1ea5y \u0111\u01b0\u1ee3c gi\u00e1 tr\u1ecb v\u1eeba x\u00f3a<\/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>Nhanh g\u1ecdn, d\u1ec5 hi\u1ec3u<\/td><td>Kh\u00f4ng linh ho\u1ea1t<\/td><\/tr><tr><td>List Comprehension<\/td><td>\u0110i\u1ec1u ki\u1ec7n l\u1ecdc<\/td><td>Kh\u00f4ng<\/td><td>R\u1ea5t linh ho\u1ea1t, ng\u1eafn g\u1ecdn<\/td><td>T\u1ea1o list m\u1edbi, kh\u00f4ng s\u1eeda list c\u0169<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">8. Khi n\u00e0o n\u00ean d\u00f9ng c\u00e1ch n\u00e0o?<\/h2>\n\n\n\n<p>T\u1eeb tr\u1ea3i nghi\u1ec7m c\u00e1 nh\u00e2n, m\u00ecnh th\u1ea5y:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>N\u1ebfu ch\u1ec9 bi\u1ebft <strong>v\u1ecb tr\u00ed ph\u1ea7n t\u1eed<\/strong>, d\u00f9ng <code>del<\/code> ho\u1eb7c <code><mark style=\"background-color:#7bdcb5\" class=\"has-inline-color\"><strong>pop()<\/strong><\/mark><\/code>.<\/li>\n\n\n\n<li>N\u1ebfu ch\u1ec9 bi\u1ebft <strong>gi\u00e1 tr\u1ecb<\/strong>, d\u00f9ng <code><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\"><strong>remove()<\/strong><\/mark><\/code>.<\/li>\n\n\n\n<li>N\u1ebfu c\u1ea7n <strong>x\u00f3a h\u00e0ng lo\u1ea1t theo \u0111i\u1ec1u ki\u1ec7n<\/strong>, d\u00f9ng <mark style=\"background-color:#ff6900\" class=\"has-inline-color\"><strong>list comprehension<\/strong><\/mark>.<\/li>\n\n\n\n<li>N\u1ebfu mu\u1ed1n d\u1ecdn s\u1ea1ch m\u1ea3ng, d\u00f9ng <code><mark style=\"background-color:#f78da7\" class=\"has-inline-color\"><strong>clear()<\/strong><\/mark><\/code>.<\/li>\n<\/ul>\n\n\n\n<p>L\u1ef1a ch\u1ecdn ph\u01b0\u01a1ng ph\u00e1p ph\u00f9 h\u1ee3p kh\u00f4ng ch\u1ec9 gi\u00fap code g\u1ecdn g\u00e0ng m\u00e0 c\u00f2n tr\u00e1nh l\u1ed7i kh\u00f4ng mong mu\u1ed1n.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. K\u1ebft lu\u1eadn<\/h2>\n\n\n\n<p>Qua b\u00e0i vi\u1ebft, m\u00ecnh \u0111\u00e3 h\u1ec7 th\u1ed1ng l\u1ea1i c\u00e1c ph\u01b0\u01a1ng ph\u00e1p x\u00f3a ph\u1ea7n t\u1eed trong m\u1ea3ng (list) \u1edf Python, g\u1ed3m: <code><strong>del<\/strong><\/code>,<strong> <code>remove()<\/code><\/strong>, <code><strong>pop()<\/strong><\/code>, <code><strong>clear()<\/strong><\/code> v\u00e0 <strong>list comprehensio<\/strong>n. M\u1ed7i ph\u01b0\u01a1ng ph\u00e1p c\u00f3 \u01b0u nh\u01b0\u1ee3c \u0111i\u1ec3m ri\u00eang, t\u00f9y t\u00ecnh hu\u1ed1ng m\u00e0 ch\u1ecdn c\u00e1ch \u00e1p d\u1ee5ng ph\u00f9 h\u1ee3p.<\/p>\n\n\n\n<p>Vi\u1ec7c th\u00e0nh th\u1ea1o c\u00e1c thao t\u00e1c n\u00e0y s\u1ebd gi\u00fap m\u00ecnh ch\u1ee7 \u0111\u1ed9ng h\u01a1n khi x\u1eed l\u00fd d\u1eef li\u1ec7u v\u00e0 vi\u1ebft code hi\u1ec7u qu\u1ea3.<\/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: Data Structures<\/em>. Retrieved from <a>https:\/\/docs.python.org\/3\/tutorial\/datastructures.html<\/a><\/li>\n\n\n\n<li>Sweigart, A. (2019). <em>Automate the Boring Stuff with Python<\/em>. No Starch Press.<\/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>Trong qu\u00e1 tr\u00ecnh l\u1eadp tr\u00ecnh v\u1edbi Python, m\u00ecnh th\u01b0\u1eddng xuy\u00ean ph\u1ea3i thao t\u00e1c v\u1edbi Array (m\u1ea3ng) ho\u1eb7c list. M\u1ed9t trong nh\u1eefng thao t\u00e1c quan tr\u1ecdng nh\u1ea5t l\u00e0 x\u00f3a ph\u1ea7n t\u1eed kh\u1ecfi m\u1ea3ng. \u0110\u00e2y kh\u00f4ng ch\u1ec9 l\u00e0 ki\u1ebfn th\u1ee9c c\u01a1 b\u1ea3n m\u00e0 c\u00f2n \u1ea3nh h\u01b0\u1edfng tr\u1ef1c ti\u1ebfp \u0111\u1ebfn hi\u1ec7u qu\u1ea3 x\u1eed l\u00fd d\u1eef li\u1ec7u, \u0111\u1eb7c bi\u1ec7t trong c\u00e1c b\u00e0i to\u00e1n y\u00eau c\u1ea7u t\u1ed1i \u01b0u v\u1ec1 b\u1ed9 nh\u1edb ho\u1eb7c t\u1ed1c \u0111\u1ed9.<\/p>\n","protected":false},"author":1,"featured_media":1690,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"googlesitekit_rrm_CAowieHDDA:productID":"","footnotes":""},"categories":[41],"tags":[40],"class_list":["post-1497","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\/1497","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=1497"}],"version-history":[{"count":3,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/posts\/1497\/revisions"}],"predecessor-version":[{"id":2441,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/posts\/1497\/revisions\/2441"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/media\/1690"}],"wp:attachment":[{"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/media?parent=1497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/categories?post=1497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/tags?post=1497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}