{"id":124970,"date":"2022-05-19T17:44:52","date_gmt":"2022-05-19T17:44:52","guid":{"rendered":"https:\/\/blog.finxter.com\/?p=375124"},"modified":"2022-05-19T17:44:52","modified_gmt":"2022-05-19T17:44:52","slug":"5-pythonic-ways-to-print-a-list-without-brackets","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2022\/05\/19\/5-pythonic-ways-to-print-a-list-without-brackets\/","title":{"rendered":"5 Pythonic Ways to Print a List without Brackets"},"content":{"rendered":"<div class=\"kk-star-ratings kksr-valign-top kksr-align-left \" data-payload=\"{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;375124&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;count&quot;:&quot;1&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;5\\\/5 - (1 vote)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;142.5&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;}\">\n<div class=\"kksr-stars\">\n<div class=\"kksr-stars-inactive\">\n<div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"kksr-stars-active\" style=\"width: 142.5px;\">\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<div class=\"kksr-legend\"> 5\/5 &#8211; (1 vote) <\/div>\n<\/div>\n<h2 class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">Problem Formulation and Solution Overview<\/h2>\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">In this article, you&#8217;ll learn how to print the contents of a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">List<\/a> without surrounding brackets in Python.<\/p>\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">To make it more fun, we have the following running scenario:<\/p>\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\"><em>You are a student and need to memorize the first 10 elements in the <a rel=\"noreferrer noopener\" href=\"https:\/\/byjus.com\/periodic-table\/\" data-type=\"URL\" data-id=\"https:\/\/byjus.com\/periodic-table\/\" target=\"_blank\">Periodic Table<\/a>. This data is currently saved in a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">List<\/a> format. However, you would prefer it to display without brackets to remove any distractions. <\/em><\/p>\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio has-global-color-8-background-color has-background\"><em><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4ac.png\" alt=\"\ud83d\udcac\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <strong>Question<\/strong>: How would we write Python code to print a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">List<\/a> without brackets?<\/em><\/p>\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">We can accomplish this task by one of the following options:<\/p>\n<ul type=\"video\" class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<li><strong>Method 1<\/strong>: Use <a href=\"https:\/\/blog.finxter.com\/python-print\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-print\/\" target=\"_blank\" rel=\"noreferrer noopener\"><code>print()<\/code><\/a> and <a href=\"https:\/\/blog.finxter.com\/python-string-join\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-join\/\"><code>join()<\/code><\/a><\/li>\n<li><strong>Method 2<\/strong>: Use <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-print\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-print\/\" target=\"_blank\"><code>print(*, sep)<\/code><\/a><\/li>\n<li><strong>Method 3<\/strong>: Use <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" target=\"_blank\"><code>slicing<\/code><\/a><\/li>\n<li><strong>Method 4<\/strong>: Use <a href=\"https:\/\/blog.finxter.com\/python-string-join\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-join\/\"><code>join()<\/code><\/a> and <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-map\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-map\/\" target=\"_blank\"><code>map()<\/code><\/a><\/li>\n<li><strong>Bonus<\/strong>: Strip quote characters from Method 3.<\/li>\n<\/ul>\n<hr class=\"wp-block-separator\"\/>\n<h2>Method 1: Use print() and join()<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">This method uses <a href=\"https:\/\/blog.finxter.com\/python-string-join\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-join\/\"><code>join()<\/code><\/a> to access each element of the <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\"><code>List<\/code><\/a> passed. Then <a href=\"https:\/\/blog.finxter.com\/python-print\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-print\/\"><code>print()<\/code><\/a> lets <a href=\"https:\/\/blog.finxter.com\/python-string-join\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-join\/\"><code>join()<\/code><\/a> know which separator to concatenate (append) to each element. The result is a <em>String<\/em>. <\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"2\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">periodic_els = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne']\nprint(' \/ '.join(periodic_els))<\/pre>\n<p>This code declares a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">List<\/a> of the first 10 element names of the <a rel=\"noreferrer noopener\" href=\"https:\/\/byjus.com\/periodic-table\/\" data-type=\"URL\" data-id=\"https:\/\/byjus.com\/periodic-table\/\" target=\"_blank\">Periodic Table<\/a> and saves them to <code>periodic_els<\/code>.<\/p>\n<p>Next, <a href=\"https:\/\/blog.finxter.com\/python-string-join\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-join\/\"><code>join()<\/code><\/a> passes <code>periodic_els<\/code> as an argument and accesses each element, adding the appropriate separator character(s) as indicated in the <a href=\"https:\/\/blog.finxter.com\/python-print\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-print\/\"><code>print<\/code><\/a> statement (<code>' \/ '<\/code>).<\/p>\n<p>Finally, the output is sent to the terminal as a <em>String data type<\/em>.<\/p>\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Python String Methods [Ultimate Guide]\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/-UkcLQxzPA4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div>\n<\/figure>\n<p><strong>Output<\/strong><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td>H \/ He \/ Li \/ Be \/ B \/ C \/ N \/ O \/ F \/ Ne<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>If we modified the <a href=\"https:\/\/blog.finxter.com\/python-print\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-print\/\"><code>print<\/code><\/a> statement to have a comma (<code>','<\/code>) as a separator, the output would be as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"2\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">elements = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne']\nprint(','.join(elements))<\/pre>\n<p><strong>Output<\/strong><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td> H,He,Li,Be,B,C,N,O,F,Ne<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4a1.png\" alt=\"\ud83d\udca1\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/>\u00a0<strong>Note<\/strong>: We recommend trying different separating characters, including a space (<code>' '<\/code>) and an empty space (<code>''<\/code>) to see the output.<\/p>\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/academy.finxter.com\/university\/the-ultimate-guide-to-python-string-methods\/\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/05\/image-235.png\" alt=\"\" class=\"wp-image-377839\" width=\"368\" height=\"637\" srcset=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/05\/image-235.png 368w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/05\/image-235-173x300.png 173w\" sizes=\"auto, (max-width: 368px) 100vw, 368px\" \/><\/a><\/figure>\n<\/div>\n<hr class=\"wp-block-separator\"\/>\n<h2>Method 2: Use print(*, sep)<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">This method uses <a href=\"https:\/\/blog.finxter.com\/python-print\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-print\/\"><code>print()<\/code><\/a> passing <code>*periodic_els<\/code>, and a separator character (<code>' '<\/code>) as arguments to the same.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"2\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">periodic_els = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne']\nprint(*periodic_els, sep=' ')<\/pre>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4a1.png\" alt=\"\ud83d\udca1\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/>&nbsp;<strong>Note<\/strong>: Placing an asterisk (<code>*<\/code>) before the variable lets Python know to unpack\/extract the variable, in this case, a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">List<\/a>.<\/p>\n<p>This code declares a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">List<\/a> of the first 10 elements in the <a rel=\"noreferrer noopener\" href=\"https:\/\/byjus.com\/periodic-table\/\" data-type=\"URL\" data-id=\"https:\/\/byjus.com\/periodic-table\/\" target=\"_blank\">Periodic Table<\/a> and saves them to <code>periodic_els<\/code>.<\/p>\n<p>Inside the <a href=\"https:\/\/blog.finxter.com\/python-print\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-print\/\"><code>print()<\/code><\/a> statement <code>*periodic_els<\/code> is passed as the first argument. This tells Python to unpack the <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">List<\/a> as indicated above. <\/p>\n<p>Next, the <code>sep<\/code> argument is passed to <a href=\"https:\/\/blog.finxter.com\/python-print\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-print\/\"><code>print()<\/code><\/a>. This will concatenate (append) character(s) between each element, in this case, a space (<code>' '<\/code>).<\/p>\n<p>Finally, the output is sent to the terminal as a <em>String data type<\/em>.<\/p>\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Python Print Function [And Its SECRET Separator &amp; End Arguments]\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/yXhEvg8Domk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div>\n<\/figure>\n<p><strong>Output<\/strong><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td> H He Li Be B C N O F Ne<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<hr class=\"wp-block-separator\"\/>\n<h2>Method 3: Use Slicing<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">This method uses <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" target=\"_blank\"><code>slicing<\/code><\/a> to remove the brackets. However, the single quote characters surrounding each element will remain.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"2\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">periodic_els = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne']\nprint(str(periodic_els)[1:-1])<\/pre>\n<p>This code declares a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">List<\/a> of the first 10 elements in the <a rel=\"noreferrer noopener\" href=\"https:\/\/byjus.com\/periodic-table\/\" data-type=\"URL\" data-id=\"https:\/\/byjus.com\/periodic-table\/\" target=\"_blank\">Periodic Table<\/a> and saves them to <code>periodic_els<\/code>.<\/p>\n<p>Next, the <a href=\"https:\/\/blog.finxter.com\/python-print\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-print\/\"><code>print()<\/code><\/a> statement converts the <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">List<\/a> to a string and then uses slicing to extract the output as indicated by <code>[1:-1]<\/code>.<\/p>\n<p>Finally, the output is sent to the terminal as a <em>String data type<\/em>.<\/p>\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"The Ultimate Guide to Slicing in Python\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/D2ZueuWXST8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div>\n<\/figure>\n<p><strong>Output<\/strong><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td> &#8216;H&#8217;, &#8216;He&#8217;, &#8216;Li&#8217;, &#8216;Be&#8217;, &#8216;B&#8217;, &#8216;C&#8217;, &#8216;N&#8217;, &#8216;O&#8217;, &#8216;F&#8217;, &#8216;Ne&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<hr class=\"wp-block-separator\"\/>\n<h2>Method 4: Use join() and map()<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">If <code>periodic_els<\/code> contained integers instead of strings, it would need to be converted to a <em>String<\/em> data type first. Then, <a href=\"https:\/\/blog.finxter.com\/python-string-join\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-join\/\"><code>join()<\/code><\/a> and <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-map\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-map\/\" target=\"_blank\"><code>map()<\/code><\/a> are used to output the contents without brackets.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"2\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">periodic_els = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nprint(', '.join(map(str, periodic_els)))<\/pre>\n<p>This code declares a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">List<\/a> of the first 10 elements in the <a rel=\"noreferrer noopener\" href=\"https:\/\/byjus.com\/periodic-table\/\" data-type=\"URL\" data-id=\"https:\/\/byjus.com\/periodic-table\/\" target=\"_blank\">Periodic Table<\/a> and saves them to <code>periodic_els<\/code>.<\/p>\n<p>Next, <code>periodic_els<\/code> is converted to a <em>String<\/em>, and the iterable <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-map\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-map\/\" target=\"_blank\"><code>map()<\/code><\/a> object is accessed. Then, each element is evaluated, and a separator character<br \/>(&#8216;, &#8216;) is placed between each element and concatenated. <\/p>\n<p>Finally, the output is sent to the terminal as a <em>String data type<\/em>.<\/p>\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Mastering the Python Map Function [+Video]\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/tqph6mWC3m8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div>\n<\/figure>\n<p><strong>Output<\/strong><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td> 1, 2, 3, 4, 5, 6, 7, 8, 9,10<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<hr class=\"wp-block-separator\"\/>\n<h2>Bonus: Strip quote characters from Method 3<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">This section expands on <strong>Method 3,<\/strong> where the resultant output contained quote characters (<code>'<\/code>) surrounding each element. This can easily be removed by running the following code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"2\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">periodic_els = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne']\nprint(str(periodic_els)[1:-1].replace(\"'\", \"\"))<\/pre>\n<p>The only difference between this code from <strong>Method 3<\/strong> and the code above is that <code><a href=\"https:\/\/blog.finxter.com\/python-string-replace-2\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-string-replace-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">replace<\/a>(\"'\", \"\")<\/code> is appended to the end.<\/p>\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Python String Replace | A Helpful Guide\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/K9-_WSh9Qkk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div>\n<\/figure>\n<p><strong>Output<\/strong><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td> H, He, Li, Be, B, C, N, O, F, Ne<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<hr class=\"wp-block-separator\"\/>\n<h2>Summary<\/h2>\n<p>These four (4) methods of how to print a List without Brackets should give you enough information to select the best one for your coding requirements.<\/p>\n<p>Good Luck &amp; Happy Coding!<\/p>\n<hr class=\"wp-block-separator\"\/>\n","protected":false},"excerpt":{"rendered":"<p>5\/5 &#8211; (1 vote) Problem Formulation and Solution Overview In this article, you&#8217;ll learn how to print the contents of a List without surrounding brackets in Python. To make it more fun, we have the following running scenario: You are a student and need to memorize the first 10 elements in the Periodic Table. This [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[857],"tags":[73,468,528],"class_list":["post-124970","post","type-post","status-publish","format-standard","hentry","category-python-tut","tag-programming","tag-python","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/124970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=124970"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/124970\/revisions"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=124970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=124970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=124970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}