{"id":24800,"date":"2019-09-16T12:15:00","date_gmt":"2019-09-16T09:15:00","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=24800"},"modified":"2020-06-23T15:01:40","modified_gmt":"2020-06-23T12:01:40","slug":"print-the-same-line-python-print-write","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/python\/print-the-same-line-python-print-write\/","title":{"rendered":"How to Print on the Same Line in Python: Print and Write"},"content":{"rendered":"\n<p>As someone who teaches a lot of beginner programming content, I occasionally stumble upon questions like \u201chow do you print on the same line in Python?\u201d Luckily, I have an answer to that!<\/p>\n\n\n\n<p><strong>In short, there are two main ways to print on the same line in Python. For Python 2, use the following print syntax: <code>print \"Williamson\",<\/code>. For Python 3, use the following print syntax: <code>print(\"Providence\", end=\"\")<\/code>. Otherwise, check out the remainder of the article for a backwards compatible solution.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Problem Introduction<\/h2>\n\n\n\n<p>In many programming languages, printing on the same line is typically the default behavior. For instance, Java has two command line print functions:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_452591\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php plain\">System.out.<\/code><code class=\"php functions\">print<\/code><code class=\"php plain\">();<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php plain\">System.out.println();<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>As you can probably imagine, the default <code>print<\/code> function in Java is going to print without a newline character. In contrast, the <code>println<\/code> function is going to behave much like the <code>print<\/code> function in Python. Specifically, it\u2019s going to print whatever string you provide to it followed by a newline character (i.e. <code>\\n<\/code>).<\/p>\n\n\n\n<p>Of course, if the <code>print<\/code> function in Python automatically prints a newline character with each call, then there\u2019s no way to get the Java <code>print<\/code> behavior, right? Luckily, that\u2019s not true! Otherwise, I wouldn\u2019t have anything to write about out.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solutions<\/h2>\n\n\n\n<p>In order to print on the same line in Python, there are a few solutions. Unfortunately, not all of the solutions work in all versions of Python, so I\u2019ve provided three solutions: one for Python 2, another for Python 3, and a final solution which works for both.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Print on the Same Line The Old Way<\/h3>\n\n\n\n<p>When I was searching for solutions to this problem, I found a lot of material on Python 2 which is quickly phasing out (I hope). That said, I felt this solution would be helpful to anyone still rocking it.<\/p>\n\n\n\n<p>At any rate, when you print something in Python 2, the syntax is the same as Python 3, but you leave out the parentheses:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_440077\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php functions\">print<\/code> <code class=\"php string\">\"Live PD\"<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>Of course, in both cases, the default behavior is to print with a newline. As a result, we\u2019ll need to add a clever bit of syntax\u2014a comma:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_696433\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php functions\">print<\/code> <code class=\"php string\">\"Live PD\"<\/code><code class=\"php plain\">,<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>Now, the print function should exclude the newline. However, <strong>this solution will add an extra space to the end of the string<\/strong>. Also, you may notice that this solution does not print immediately. If that happens, you can make a call to <code>sys.stdout.flush()<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Print on the Same Line with the Write Function<\/h3>\n\n\n\n<p>Fortunately, we can bridge the gap between Python 2 and 3 using a function out of the <code>sys<\/code> library: <code>write<\/code>. This functions works just like the <code>print<\/code> function, but there\u2019s no implicit newline:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_406050\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php plain\">import sys<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php plain\">sys.stdout.write(<\/code><code class=\"php string\">\"Breaking Bad\"<\/code><code class=\"php plain\">)<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>Again, since there is no newline, you may need to flush the buffer to see any results:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_551206\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php plain\">import sys<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php plain\">sys.stdout.write(<\/code><code class=\"php string\">\"Breaking Bad\"<\/code><code class=\"php plain\">)<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"php plain\">sys.stdout.<\/code><code class=\"php functions\">flush<\/code><code class=\"php plain\">()<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>In either case, this solution will get the job done in both versions of Python.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Print on the Same Line the New Way<\/h3>\n\n\n\n<p>In Python 3, <code>print<\/code> is a standard function. As a result, it has additional opportunities for parameters. In particular, there is a keyword argument called <code>end<\/code> which defaults to some newline character. You can easily change it as follows:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_70849\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php functions\">print<\/code><code class=\"php plain\">(<\/code><code class=\"php string\">\"Mob Psycho 100\"<\/code><code class=\"php plain\">, <\/code><code class=\"php functions\">end<\/code><code class=\"php plain\">=<\/code><code class=\"php string\">\"\"<\/code><code class=\"php plain\">)<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>And, that\u2019s it! Instead of the string ending in a newline, it will end in an empty string. Of course, this solution comes with the same caveat as the other previous two solutions: you may need to flush the buffer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Performance<\/h2>\n\n\n\n<p>As always, I like to take a look at all the solutions from the point of view of performance. To start, I usually store each solution in a string. To avoid excessive printing during the test, I\u2019ve chosen to write empty strings:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_300345\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">01<\/div>\n<div class=\"line number2 index1 alt1\">02<\/div>\n<div class=\"line number3 index2 alt2\">03<\/div>\n<div class=\"line number4 index3 alt1\">04<\/div>\n<div class=\"line number5 index4 alt2\">05<\/div>\n<div class=\"line number6 index5 alt1\">06<\/div>\n<div class=\"line number7 index6 alt2\">07<\/div>\n<div class=\"line number8 index7 alt1\">08<\/div>\n<div class=\"line number9 index8 alt2\">09<\/div>\n<div class=\"line number10 index9 alt1\">10<\/div>\n<div class=\"line number11 index10 alt2\">11<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php plain\">setup=<\/code><code class=\"php string\">\"\"<\/code><code class=\"php plain\">\"<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php plain\">import sys<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"php string\">\"\"<\/code><code class=\"php plain\">\"<\/code><\/div>\n<div class=\"line number4 index3 alt1\">&nbsp;<\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"php plain\">write_solution = <\/code><code class=\"php string\">\"\"<\/code><code class=\"php plain\">\"<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"php plain\">sys.stdout.write(<\/code><code class=\"php string\">\"\"<\/code><code class=\"php plain\">)<\/code><\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"php string\">\"\"<\/code><code class=\"php plain\">\"<\/code><\/div>\n<div class=\"line number8 index7 alt1\">&nbsp;<\/div>\n<div class=\"line number9 index8 alt2\"><code class=\"php plain\">print_solution = <\/code><code class=\"php string\">\"\"<\/code><code class=\"php plain\">\"<\/code><\/div>\n<div class=\"line number10 index9 alt1\"><code class=\"php functions\">print<\/code><code class=\"php plain\">(<\/code><code class=\"php string\">\"\"<\/code><code class=\"php plain\">, <\/code><code class=\"php functions\">end<\/code><code class=\"php plain\">=<\/code><code class=\"php string\">\"\"<\/code><code class=\"php plain\">)<\/code><\/div>\n<div class=\"line number11 index10 alt2\"><code class=\"php string\">\"\"<\/code><code class=\"php plain\">\"<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>Unfortunately, I was unable to test the Python 2 solution on my system, so feel free to share your results in the comments. At any rate, I like to use the <code>timeit<\/code> library for a quick and dirty performance test:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_759704\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php plain\">&gt;&gt;&gt; import timeit<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php plain\">&gt;&gt;&gt; min(timeit.repeat(stmt=write_solution, setup=setup, repeat=10))<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"php plain\">0.20978069999999605<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"php plain\">&gt;&gt;&gt; min(timeit.repeat(stmt=print_solution, setup=setup, repeat=10))<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"php plain\">0.5292953999999952<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>Clearly, the <code>print<\/code> function has quite a bit of overhead. In other words, if performance matters, go the <code>write<\/code> route. Otherwise, <code>print<\/code> works great!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Little Recap<\/h2>\n\n\n\n<p>Well, that\u2019s it for this one. Check out the code block below for a list of all the solutions:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_231736\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<div class=\"line number7 index6 alt2\">7<\/div>\n<div class=\"line number8 index7 alt1\">8<\/div>\n<div class=\"line number9 index8 alt2\">9<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php plain\"># Python 2 only<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php functions\">print<\/code> <code class=\"php string\">\"Live PD\"<\/code><code class=\"php plain\">,<\/code><\/div>\n<div class=\"line number3 index2 alt2\">&nbsp;<\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"php plain\"># Backwards compatible (also fastest)<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"php plain\">import sys<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"php plain\">sys.stdout.write(<\/code><code class=\"php string\">\"Breaking Bad\"<\/code><code class=\"php plain\">)<\/code><\/div>\n<div class=\"line number7 index6 alt2\">&nbsp;<\/div>\n<div class=\"line number8 index7 alt1\"><code class=\"php plain\"># Python 3 only<\/code><\/div>\n<div class=\"line number9 index8 alt2\"><code class=\"php functions\">print<\/code><code class=\"php plain\">(<\/code><code class=\"php string\">\"Mob Psycho 100\"<\/code><code class=\"php plain\">, <\/code><code class=\"php functions\">end<\/code><code class=\"php plain\">=<\/code><code class=\"php string\">\"\"<\/code><code class=\"php plain\">)<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>As always, if you know any other ways to print on the same line in Python, let us know in the comments. In the meantime, why not grow your Python knowledge with the following articles:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/therenegadecoder.com\/code\/how-to-invert-a-dictionary-in-python\/\">How to Invert a Dictionary in Python<\/a><\/li><li><a href=\"https:\/\/therenegadecoder.com\/code\/how-to-check-if-a-list-is-empty-in-python\/\">How to Check if a List in Empty in Python<\/a><\/li><\/ul>\n\n\n\n<p>If you liked this article or any of the ones I listed, consider sticking around long term by <a href=\"https:\/\/www.patreon.com\/TheRenegadeCoder\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"becoming a member of the community (opens in a new tab)\">becoming a member of the community<\/a> or <a href=\"https:\/\/newsletter.therenegadecoder.com\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"hopping on the mailing list (opens in a new tab)\">hopping on the mailing list<\/a>.<\/p>\n\n\n\n<p>While you\u2019re here, why not take advantage of some these Python books:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.amazon.com\/Python-Programming-Beginners-Step-Step\/dp\/1075705576\/ref=as_li_ss_tl?adId=1075705576&amp;ref-refURL=https:\/\/therenegadecoder.com\/&amp;slotNum=0&amp;imprToken=Qt18CDdoJo59NU7fxv6K7g&amp;adType=smart&amp;adMode=manual&amp;adFormat=card&amp;impressionTimestamp=1566697995330&amp;linkCode=ll1&amp;tag=renegadecoder-20&amp;linkId=d1b2df3c9b55e406e4cac7bedcd9f766&amp;language=en_US\">Python Programming: A Smart Approach For Absolute Beginners (A Step-by-Step Guide With 8 Days Crash Course)<\/a> by Steve Manson<\/li><li><a href=\"https:\/\/www.amazon.com\/Python-Programming-Practical-Exercises-Interview\/dp\/1081450339\/ref=as_li_ss_tl?adId=1081450339&amp;ref-refURL=https:\/\/therenegadecoder.com\/&amp;slotNum=1&amp;imprToken=VgzXfwzkJGElZarrYnZkyg&amp;adType=smart&amp;adMode=manual&amp;adFormat=card&amp;impressionTimestamp=1566697995377&amp;linkCode=ll1&amp;tag=renegadecoder-20&amp;linkId=dfbf5a795e773b978fb4fb5e92f824d1&amp;language=en_US\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Python Programming: A Smarter And Faster Way To Learn Python In 7 Days: With Practical Exercises, Interview Questions, Tips And Tricks (opens in a new tab)\">Python Programming: A Smarter And Faster Way To Learn Python In 7 Days: With Practical Exercises, Interview Questions, Tips And Tricks<\/a> by Chris Harvard<\/li><\/ul>\n\n\n\n<p>Otherwise, I appreciate the support. Thanks for stopping by!<\/p>\n\n\n\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Web Code Geeks with permission by Jeremy Grifski, partner at our <a href=\"\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">WCG program<\/a>. See the original article here: <a href=\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Print on the Same Line in Python: Print and Write<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>As someone who teaches a lot of beginner programming content, I occasionally stumble upon questions like \u201chow do you print on the same line in Python?\u201d Luckily, I have an answer to that! In short, there are two main ways to print on the same line in Python. For Python 2, use the following print &hellip;<\/p>\n","protected":false},"author":14722,"featured_media":1651,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[],"class_list":["post-24800","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Print on the Same Line in Python: Print and Write - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn about Print and Write? Check our article explaining the two main ways to print on the same line in Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Print on the Same Line in Python: Print and Write - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Print and Write? Check our article explaining the two main ways to print on the same line in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-16T09:15:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-23T12:01:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jeremy Grifski\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@RenegadeCoder94\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeremy Grifski\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/print-the-same-line-python-print-write\/\"},\"author\":{\"name\":\"Jeremy Grifski\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7eaa8e89cf23a5de82a048beb4c59aa1\"},\"headline\":\"How to Print on the Same Line in Python: Print and Write\",\"datePublished\":\"2019-09-16T09:15:00+00:00\",\"dateModified\":\"2020-06-23T12:01:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/print-the-same-line-python-print-write\/\"},\"wordCount\":863,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/print-the-same-line-python-print-write\/\",\"url\":\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/\",\"name\":\"How to Print on the Same Line in Python: Print and Write - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"datePublished\":\"2019-09-16T09:15:00+00:00\",\"dateModified\":\"2020-06-23T12:01:40+00:00\",\"description\":\"Interested to learn about Print and Write? Check our article explaining the two main ways to print on the same line in Python.\",\"breadcrumb\":{\"@id\":\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Print on the Same Line in Python: Print and Write\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7eaa8e89cf23a5de82a048beb4c59aa1\",\"name\":\"Jeremy Grifski\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9d50311a27dff0a54d775b6106b8f804d5d11d0b5182ed537f325046a020c6f5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9d50311a27dff0a54d775b6106b8f804d5d11d0b5182ed537f325046a020c6f5?s=96&d=mm&r=g\",\"caption\":\"Jeremy Grifski\"},\"description\":\"Jeremy is the founder of The Renegade Coder, a software curriculum website launched in 2017. In addition, he is a PhD student with an interest in education and data visualization.\",\"sameAs\":[\"https:\/\/therenegadecoder.com\/\",\"https:\/\/www.linkedin.com\/in\/jeremy-grifski-22240552\/\",\"https:\/\/x.com\/RenegadeCoder94\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/jeremy-grifski\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Print on the Same Line in Python: Print and Write - Web Code Geeks - 2026","description":"Interested to learn about Print and Write? Check our article explaining the two main ways to print on the same line in Python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/","og_locale":"en_US","og_type":"article","og_title":"How to Print on the Same Line in Python: Print and Write - Web Code Geeks - 2026","og_description":"Interested to learn about Print and Write? Check our article explaining the two main ways to print on the same line in Python.","og_url":"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2019-09-16T09:15:00+00:00","article_modified_time":"2020-06-23T12:01:40+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","type":"image\/jpeg"}],"author":"Jeremy Grifski","twitter_card":"summary_large_image","twitter_creator":"@RenegadeCoder94","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Jeremy Grifski","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/python\/print-the-same-line-python-print-write\/"},"author":{"name":"Jeremy Grifski","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7eaa8e89cf23a5de82a048beb4c59aa1"},"headline":"How to Print on the Same Line in Python: Print and Write","datePublished":"2019-09-16T09:15:00+00:00","dateModified":"2020-06-23T12:01:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/python\/print-the-same-line-python-print-write\/"},"wordCount":863,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/python\/print-the-same-line-python-print-write\/","url":"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/","name":"How to Print on the Same Line in Python: Print and Write - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#primaryimage"},"image":{"@id":"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","datePublished":"2019-09-16T09:15:00+00:00","dateModified":"2020-06-23T12:01:40+00:00","description":"Interested to learn about Print and Write? Check our article explaining the two main ways to print on the same line in Python.","breadcrumb":{"@id":"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/therenegadecoder.com\/code\/how-to-print-on-the-same-line-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/www.webcodegeeks.com\/category\/python\/"},{"@type":"ListItem","position":3,"name":"How to Print on the Same Line in Python: Print and Write"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7eaa8e89cf23a5de82a048beb4c59aa1","name":"Jeremy Grifski","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9d50311a27dff0a54d775b6106b8f804d5d11d0b5182ed537f325046a020c6f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9d50311a27dff0a54d775b6106b8f804d5d11d0b5182ed537f325046a020c6f5?s=96&d=mm&r=g","caption":"Jeremy Grifski"},"description":"Jeremy is the founder of The Renegade Coder, a software curriculum website launched in 2017. In addition, he is a PhD student with an interest in education and data visualization.","sameAs":["https:\/\/therenegadecoder.com\/","https:\/\/www.linkedin.com\/in\/jeremy-grifski-22240552\/","https:\/\/x.com\/RenegadeCoder94"],"url":"https:\/\/www.webcodegeeks.com\/author\/jeremy-grifski\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/24800","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/14722"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=24800"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/24800\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/1651"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=24800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=24800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=24800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}