{"id":17349,"date":"2020-11-24T22:42:10","date_gmt":"2020-11-25T06:42:10","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=17349"},"modified":"2023-12-01T04:04:57","modified_gmt":"2023-12-01T12:04:57","slug":"python-f-string","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-f-string\/","title":{"rendered":"Python f Strings: The Ultimate Guide"},"content":{"rendered":"\n<p><em>Python f strings embed expressions into a string. An expression may be the contents of a <\/em><em>variab<\/em><em>le or the result of a mathematical calculation, or another Python value. f strings are distinguished from regular strings as the letter f comes before the string.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>When you\u2019re writing a string, you may want to change part of a string to use a specific value. For instance, you may want a string to appear that contains the value the user has inserted into the console.\n\n<\/p>\n\n\n\n<p>Python has supported string formatting for a while, but Python 3.6 introduced a new method of changing strings to include new values: f strings.\n\n<\/p>\n\n\n\n<p>This tutorial will discuss, with reference to examples, the basics of f strings in Python. By the end of reading this tutorial, you\u2019ll be an expert at using Python f strings.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python String Formatting<\/h2>\n\n\n\n<p>Prior to Python 3.6, there were two ways you could format <a href=\"https:\/\/careerkarma.com\/blog\/python-substring\/\">Python string<\/a>. You could use the percentage (%) formatting, and <em>str.format()<\/em>.\n\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Percentage Formatting<\/h3>\n\n\n\n<p>Percentage formatting has been around since the beginning and allows you to format a string with one or multiple values.<\/p>\n\n\n\n<p>Here\u2019s an example of the percentage formatting approach in action:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>email = &quot;lindsay.ballantyne@gmail.com&quot;\nnew_string = &quot;Your email address is %s.&quot; % email\nprint(new_string)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Your email address is lindsay.ballantyne@gmail.com<\/pre><\/div>\n\n\n\n<p>In our code, we use the %s sign as a placeholder for our new string in the \u201cYour email address is %s.\u201d string. At the end of that line of code, we use a percentage sign followed by \u201cemail\u201d to replace %s with our user\u2019s email address.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">str.format()<\/h3>\n\n\n\n<p>In Python 2.6, a new method of formatting strings was introduced: the <em>format()<\/em> function.\n\n<\/p>\n\n\n\n<p>Suppose we want to format a string with two values. We could do so using the <em>format()<\/em> method like so:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>name = &quot;Lindsay Ballantyne&quot;\nemail = &quot;lindsay.ballantyne@gmail.com&quot;\nnew_string = &quot;Hello, {}. Your email address is {}.&quot;.format(name, email)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Hello, Lindsay Ballantyne. Your email address is lindsay.ballantyne@gmail.com.<\/pre><\/div>\n\n\n\n<p>In our code, we define two <a href=\"https:\/\/careerkarma.com\/blog\/python-variables\/\">Python variables<\/a>, \u201cname\u201d and \u201cemail\u201d. These variables store the name and email address of someone using our program. Then, we use the <em>.format()<\/em> syntax to add in the values \u201cname\u201d and \u201cemail\u201d to our string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python f String Format<\/h2>\n\n\n\n<p>Python f strings embed expressions into a string literal. You can use f strings to embed variables, strings, or the results of functions into a string. An f string are prefixed with &#8220;f&#8221; at the start, before the string iitself begins.<\/p>\n\n\n\n<p>Introduced in Python 3.6, make it easier to format strings.&nbsp;<\/p>\n\n\n\n<p><em>f strings<\/em> use curly braces to store the values which should be formatted into a string. f strings can also use a capital \u201cF\u201d to represent a formatted string.<\/p>\n\n\n\n<p>Consider this syntax:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>f&quot;This is a string.&quot;<\/pre><\/div>\n\n\n\n<p>We have just defined a formatted string literal. We can add values to the string using curly brackets: {}.<\/p>\n\n\n\n<p>Some people refer to string formatting as string interpolation. These two concepts refer to the same idea: adding a value into another string.<\/p>\n\n\n\n<p>Let&#8217;s take a look at an example of an f string in action.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">f String Python Example<\/h2>\n\n\n\n<p>Suppose we want to add the name \u201cLindsay Ballantyne\u201d to a string. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>name = &quot;Lindsay Ballantyne&quot;\nprint(f&quot;Your name is {name}.&quot;)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Your name is Lindsay Ballantyne.<\/pre><\/div>\n\n\n\n<p>In our code, we declare a variable called \u201cname\u201d which stores the name of our user. Then, we use an f string to add the value \u201cLindsay Ballantyne\u201d into a string.\n\n<\/p>\n\n\n\n<p>This shows that you can directly insert the value of a variable into an f string. The syntax is easier than all of the other formatting options, such as the format() method or a % string.\n\n<\/p>\n\n\n\n<p>That\u2019s not all. f strings can also support functions or any other expression, evaluated inside the string. Suppose we wanted to perform a <a href=\"https:\/\/careerkarma.com\/blog\/python-math-operators\/\">Python mathematical function<\/a> in an f string. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>name = &quot;Lindsay Ballantyne&quot;\nprint(f&quot;Your name is {name}. On your next birthday, you will be {22 + 1}.&quot;)<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Your name is Lindsay Ballantyne. On your next birthday, you will be 23.<\/pre><\/div>\n\n\n\n<p>We were able to perform a mathematical function.<\/p>\n\n\n\n<p>This is because expressions in string literals are evaluated at run-time, and they are part of the main program. Our mathematical function was \u201c22 + 1\u201d, which we performed by enclosing the function within curly brackets.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Multiline Python f Strings<\/h2>\n\n\n\n<p>The f string syntax supports multiline string formatting. You can create a multiline Python f string by enclosing multiple f strings in curly brackets.<\/p>\n\n\n\n<p>Suppose we wanted to format values in a multiline string. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>name = &quot;Lindsay Ballantyne&quot;\nemail = &quot;lindsay.ballantyne@gmail.com&quot;\nage = 22\n\nprofile = (\n\tf&quot;Name: {name} \\n&quot;\n\tf&quot;Email: {email} \\n&quot;\n\tf&quot;Age: {age} \\n&quot;\n)\n\nprint(profile)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Name: Lindsay Ballantyne\nEmail: lindsay.ballantyne@gmail.com\nAge: 22<\/pre><\/div>\n\n\n\n<p>In our code, we declared three variables \u2014 name, email, and age \u2014 which store information about our user. Then, we created a multiline string which is formatted using those variables.\n\n<\/p>\n\n\n\n<p>Notice how, in our code, we placed an f before each line in our multiline string. This is because, if you don\u2019t place an f in front of each line, the f string syntax will not be used.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">f String Special Characters<\/h2>\n\n\n\n<p>There\u2019s still one thing you need to learn before you start using f strings in your code. You need to know how to handle special characters with f strings.\n\n<\/p>\n\n\n\n<p>Here are a few rules you should keep in mind as you use f strings.\n\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Quotation Marks<\/h3>\n\n\n\n<p>When you\u2019re using f strings, you can use quotation marks in your expressions. But, you need to use a different type of quotation mark than you are using outside your f string. Here\u2019s an example of quotation marks being used in an f string:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(f&quot;{'It is Thursday!'}&quot;)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>It is Thursday<\/pre><\/div>\n\n\n\n<p>Notice that we used single quotes (\u2018) inside our f string (which is denoted using curly braces), and double quotes (\u201c\u201d) to represent our full string.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Dictionaries<\/h3>\n\n\n\n<p>To reference a value in a <a href=\"https:\/\/careerkarma.com\/blog\/python-dictionary\/\">Python dictionary<\/a>, you\u2019ll need to use quotation marks. You should make sure that you use a different kind of quotation mark when you reference each value in your dictionary.\n\n<\/p>\n\n\n\n<p>Here\u2019s an example of working with a dictionary and an f string:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>user = {name: &quot;Lindsay Ballantyne&quot;, email: &quot;lindsay.ballantyne@gmail.com&quot;}\nprint(f{&quot;Hello, {user['name']}. Your email address is: {user['email']}.&quot;)<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Hello, Lindsay Ballantyne. Your email address is: lindsay.ballantyne@gmail.com<\/pre><\/div>\n\n\n\n<p>Note that, when we\u2019re referring to values in our dictionary, we use single quotes (\u2018\u2019). Our main f string uses double quotes (\u201c\u201d). This prevents any string formatting errors from arising in our code.\n\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Curly Braces<\/h3>\n\n\n\n<p>To use a curly brace in an f string, you need to use double braces. Here\u2019s an example of curly braces in an f string:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(f&quot;{{This is a test}}&quot;)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>{This is a test}<\/pre><\/div>\n\n\n\n<p>You can see that only one set of braces appeared in our end result. This is because one set of braces is used by the f string to denote that string formatting is going to take place. So, only the one set of braces inside your curly braces will appear.\n\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Comments<\/h3>\n\n\n\n<p>When you\u2019re writing an f string, your f string should not include a hashtag (#) sign. This sign denotes a comment in Python, and will cause a syntax error.\n\n<\/p>\n\n\n\n<p>If you want to use a hashtag in a string, make sure it is formatted in the string, instead of the f string. Here\u2019s an example of this in action:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>user_id = &quot;202&quot;\nprint(f&quot;User ID: #{user_id}&quot;)<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>User ID: #202<\/pre><\/div>\n\n\n\n<p>We added our hashtag in before our f string curly braces. We did this to make sure that our hashtag would appear correctly in our string.<\/p>\n\n\n\n<p><strong>View the Repl.it from this tutorial:<\/strong><\/p>\n\n\n\n<iframe loading=\"lazy\" src=\"https:\/\/repl.it\/@careerkarma\/Python-String-Formatting?lite=true\" width=\"100%\" height=\"400px\" frameborder=\"0\"><\/iframe>\n<br>\n<br>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Python f strings are a new tool you can use to put expressions inside string literals.<\/p>\n\n\n\n<p>The advantages of using f strings over previous options are numerous. f strings are easier to read. They work well even when you\u2019re working with many values.<\/p>\n\n\n\n<p>This tutorial discussed, with reference to examples, how f strings compare to other string formatting options, and how to use f strings in your code. Now you have the knowledge you need to start working with Python f strings like a professional developer!<\/p>\n\n\n\n<p>If you want to learn more about Python, check out our <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">How to Learn Python guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"Python f strings embed expressions into a string. An expression may be the contents of a variable or the result of a mathematical calculation, or another Python value. f strings are distinguished from regular strings as the letter f comes before the string. When you\u2019re writing a string, you may want to change part of&hellip;","protected":false},"author":240,"featured_media":17350,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-17349","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Python","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python f Strings: The Ultimate Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Python f strings allow you to concisely format strings in Python. On Career Karma, learn how to embed expressions in a string using f strings.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/python-f-string\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python f Strings: The Ultimate Guide\" \/>\n<meta property=\"og:description\" content=\"Python f strings allow you to concisely format strings in Python. On Career Karma, learn how to embed expressions in a string using f strings.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-f-string\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-25T06:42:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:04:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/two-macbook-pro-beside-gray-bowl-705675.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"574\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python f Strings: The Ultimate Guide\",\"datePublished\":\"2020-11-25T06:42:10+00:00\",\"dateModified\":\"2023-12-01T12:04:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/\"},\"wordCount\":1256,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/two-macbook-pro-beside-gray-bowl-705675.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-f-string\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/\",\"name\":\"Python f Strings: The Ultimate Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/two-macbook-pro-beside-gray-bowl-705675.jpg\",\"datePublished\":\"2020-11-25T06:42:10+00:00\",\"dateModified\":\"2023-12-01T12:04:57+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Python f strings allow you to concisely format strings in Python. On Career Karma, learn how to embed expressions in a string using f strings.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-f-string\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/two-macbook-pro-beside-gray-bowl-705675.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/two-macbook-pro-beside-gray-bowl-705675.jpg\",\"width\":1020,\"height\":574},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-f-string\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/careerkarma.com\/blog\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python f Strings: The Ultimate Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python f Strings: The Ultimate Guide | Career Karma","description":"Python f strings allow you to concisely format strings in Python. On Career Karma, learn how to embed expressions in a string using f strings.","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:\/\/careerkarma.com\/blog\/python-f-string\/","og_locale":"en_US","og_type":"article","og_title":"Python f Strings: The Ultimate Guide","og_description":"Python f strings allow you to concisely format strings in Python. On Career Karma, learn how to embed expressions in a string using f strings.","og_url":"https:\/\/careerkarma.com\/blog\/python-f-string\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-11-25T06:42:10+00:00","article_modified_time":"2023-12-01T12:04:57+00:00","og_image":[{"width":1020,"height":574,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/two-macbook-pro-beside-gray-bowl-705675.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-f-string\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-f-string\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python f Strings: The Ultimate Guide","datePublished":"2020-11-25T06:42:10+00:00","dateModified":"2023-12-01T12:04:57+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-f-string\/"},"wordCount":1256,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-f-string\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/two-macbook-pro-beside-gray-bowl-705675.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-f-string\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-f-string\/","url":"https:\/\/careerkarma.com\/blog\/python-f-string\/","name":"Python f Strings: The Ultimate Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-f-string\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-f-string\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/two-macbook-pro-beside-gray-bowl-705675.jpg","datePublished":"2020-11-25T06:42:10+00:00","dateModified":"2023-12-01T12:04:57+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Python f strings allow you to concisely format strings in Python. On Career Karma, learn how to embed expressions in a string using f strings.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-f-string\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-f-string\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-f-string\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/two-macbook-pro-beside-gray-bowl-705675.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/two-macbook-pro-beside-gray-bowl-705675.jpg","width":1020,"height":574},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-f-string\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/careerkarma.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python f Strings: The Ultimate Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/17349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=17349"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/17349\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/17350"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=17349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=17349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=17349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}