{"id":12278,"date":"2020-07-20T17:00:36","date_gmt":"2020-07-21T00:00:36","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=12278"},"modified":"2023-12-01T03:55:30","modified_gmt":"2023-12-01T11:55:30","slug":"python-string-to-int","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/","title":{"rendered":"Python String to Int() and Int to String Tutorial: Type Conversion in Python"},"content":{"rendered":"\n<p><strong>How to Convert Python String to Int:<br><\/strong><em>To convert a string to integer in Python, use the <code>int()<\/code> function. This function takes two parameters: the initial string and the optional base to represent the data. Use the syntax <code>print(int(\"STR\"))<\/code> to return the <code>str<\/code> as an <code>int<\/code>, or integer.<\/em><\/p>\n\n\n\n<p> <strong>How to Convert Python Int to String:<\/strong><br><em>To convert an integer to string in Python, use the <code>str()<\/code> function. This function takes any data type and converts it into a string, including integers. Use the syntax <code>print(str(INT))<\/code> to return the <code>int<\/code> as a <code>str<\/code>, or string.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>When <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">learning how to code with Python<\/a>, students quickly find that Python includes a number of data types that are used to distinguish a particular type of data. For example,<a href=\"https:\/\/careerkarma.com\/blog\/python-string-methods\/\"> Python strings<\/a> are used to represent text-based data, and integers can represent whole numbers. When you\u2019re programming, you may want to convert values between different data types so you can work with them in different ways.<br><\/p>\n\n\n\n<p>One common operation is to convert a Python string to an integer or an integer to a string. Python includes built-in methods that can be used to perform these conversions: <code>int()<\/code> and <code>str()<\/code>. <\/p>\n\n\n\n<p>In this tutorial, we\u2019ll explore how the<code> int()<\/code> method can be used to convert a string to an integer in Python. We&#8217;ll also discuss how to use <code>str() <\/code>to convert an integer to a string.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-data-types\">Python Data Types<\/h2>\n\n\n\n<p>When you\u2019re <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-programming-in-python\/\">programming in Python<\/a>, the data you are working with will be stored in a number of different ways. If you\u2019re working with text, your data will be stored as a string. But if you\u2019re working with a decimal number, your data will be structured as a float.<\/p>\n\n\n\n<p>This is important because each type of data can be manipulated in different ways. Thus, Python needs to store different sorts of data using different data types. There are a number of <a href=\"https:\/\/careerkarma.com\/blog\/python-data-types\/\">data types in Python<\/a> that are used to store data, including numbers, Booleans, and lists.<\/p>\n\n\n\n<p>In this article, we will focus on two of these data types: strings and numbers.<\/p>\n\n\n\n<p><a href=\"https:\/\/careerkarma.com\/blog\/what-python-is-used-for\/\">In Python<\/a>, strings are enclosed within single or double quotes and are used to represent text-based information. Here\u2019s an example of a string:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>text_data = \"This string contains text-based data.\"<\/pre><\/div>\n\n\n\n<p>The number data type is used to store both decimal and whole numbers. Decimal numbers will automatically be converted into a float, and whole numbers will be considered an integer. Here\u2019s an example of an integer and a <a href=\"https:\/\/careerkarma.com\/blog\/python-float\/\">floating-point number in Python<\/a>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>example_integer = 22\nexample_float = 2.22<\/pre><\/div>\n\n\n\n<p>Converting a data type to another form of data is called <strong>type conversion<\/strong>. If you want to convert a string to an integer or an integer to a string, you will be performing a type conversion operation<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-string-to-int\">Python String to Int<\/h2>\n\n\n\n<p>The <code>int()<\/code> method can be used to convert a string to an integer value in Python.<\/p>\n\n\n\n<p><code>int()<\/code> takes in two parameters: the string to convert into an integer and the base you want your data to be represented in. The second parameter is optional.<\/p>\n\n\n\n<p>The method returns the value you passed through <code>int()<\/code>, represented as an integer. Here\u2019s the syntax for the Python <code>int()<\/code> method:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>int(number, base=base)<\/pre><\/div>\n\n\n\n<p>Here\u2019s an example of the <code>int()<\/code> method being used to convert a string to an integer: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(int(\"12\"))<\/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>12<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-an-example-of-string-to-int-in-action\">An Example of String to Int in Action<\/h3>\n\n\n\n<p>Let\u2019s use a more detailed example to show how the <code>int()<\/code> method can be used. Say that we are creating a sign up form for a children\u2019s game that asks for the user\u2019s age. We need this value to be stored as an integer in our database. But when a user inserts the value in our program their age becomes a string.<\/p>\n\n\n\n<p>Let\u2019s create a program that performs this function. We\u2019ll start by using the <code>input()<\/code> method to get a user\u2019s age:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>raw_user_age = input(\"What is your age?\")\nprint(raw_user_age)<\/pre><\/div>\n\n\n\n<p>When our user enters a number, it will be printed out to the console. Here\u2019s what happens when we run our program: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>What is your age?\n12\n12<\/pre><\/div>\n\n\n\n<p>The value the user inserted is <code>12<\/code>. This may look like a number. However, when we use the <code>type()<\/code> method to check the data type for our user\u2019s age, we see it isn&#8217;t a number. We can use the following code to check the data type of our user\u2019s age:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(type(raw_user_age))<\/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>&lt;class 'str'&gt;<\/pre><\/div>\n\n\n\n<p>As you can see, our data is stored as a <code>str<\/code>, or a string. So, it\u2019s clear that we need to convert our data to an integer. We can do so by using the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>raw_user_age = input(\"What is your age?\")\nuser_age = int(raw_user_age)\nprint(user_age)<\/pre><\/div>\n\n\n\n<p>Here\u2019s what happens when we execute our code and insert the value <code>12<\/code>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>What is your age?\n12\n12<\/pre><\/div>\n\n\n\n<p>Our code returns the same output as above, but <code>12<\/code> is now stored as a integer. We can use the <code>type()<\/code> method to check: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(type(user_age))<\/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>&lt;class 'int'&gt;<\/pre><\/div>\n\n\n\n<p>Now our value is stored as an integer like we initially wanted.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-int-to-string\"><strong>Python Int to String<\/strong><\/h2>\n\n\n\n<p>The str() method allows you to convert an integer to a string in Python. The syntax for this method is:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>str(number_to_convert)\n<\/pre><\/div>\n\n\n\n<p>Let&#8217;s walk through an example to show how this method works. In our earlier example, we converted the user&#8217;s age to an integer using this code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>raw_user_age = input(\"What is your age?\")\nuser_age = int(raw_user_age)\n<\/pre><\/div>\n\n\n\n<p>Let&#8217;s say that we want to print a message with our user&#8217;s age to the console. We could do this by using the following code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(\"Your age is: \" + user_age)\n<\/pre><\/div>\n\n\n\n<p>Our code returns an error:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Traceback (most recent call last):\n  File \"main.py\", line 3, in &lt;module&gt;\n\tprint(\"Your age is: \" + user_age)\nTypeError: can only concatenate str (not \"int\") to str\n<\/pre><\/div>\n\n\n\n<p>This is because you cannot concatenate a string to an integer like we have tried to do above. To make our code work, we&#8217;re going to have to convert our user&#8217;s age to a string. We can do this by using the <code>str()<\/code> method:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>raw_user_age = input(\"What is your age?\")\nuser_age = int(raw_user_age)\nas_string = str(user_age)\nprint(\"Your age is: \" + as_string)\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p>What is your age?<\/p>\n\n\n\n<p>12<\/p>\n\n\n\n<p>Your age is: 12<br><\/p>\n\n\n\n<p>We&#8217;ve successfully converted our integer to a string using str(). Both values are now strings, which means that we can now concatenate the message <code>Your age is:<\/code>  with the user&#8217;s age.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-convert-list-of-strings-to-list-of-integers\">Python Convert List of Strings to List of Integers<\/h2>\n\n\n\n<p>Suppose we have a list of strings that contains the grades students have earned in a computer science class. We want to convert every grade in our list into an integer. To do this, we can use a <a href=\"https:\/\/careerkarma.com\/blog\/python-list-comprehension\/\">Python list comprehension<\/a>.<\/p>\n\n\n\n<p>A list comprehension makes it easy to create a new list based on the contents of an existing list. In this case, we will use a list comprehension to turn a list of strings into a new list of integers.<\/p>\n\n\n\n<p>Consider this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>grades = [\"82\", \"84\", \"71\", \"64\", \"66\"]\nnew_grades = [int(g) for g in grades]\nprint(new_grades)<\/pre><\/div>\n\n\n\n<p>First, we define a list called &#8220;grades&#8221;. This list contains strings. We then write a list comprehension that converts every value in our &#8220;grades&#8221; list into an integer. Our list comprehension does this by iterating over every value in &#8220;grades&#8221; and changing their data type using the int() function.<\/p>\n\n\n\n<p>At the end of our program, we print our new list of integers:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>[82, 84, 71, 64, 66]<\/pre><\/div>\n\n\n\n<p>Our code has successfully converted our list of strings into a list of integers.<\/p>\n\n\n\n<iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/5MPeklTf9QA\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\" width=\"560\" height=\"315\" frameborder=\"0\"><\/iframe>\n\n\n\n<iframe loading=\"lazy\" src=\"https:\/\/repl.it\/@careerkarma\/Python-String-to-Int?lite=true\" scrolling=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" sandbox=\"allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals\" width=\"100%\" height=\"400px\" frameborder=\"no\"><\/iframe>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>The int() method is used to convert a string to an integer in Python. This can be useful if you need to store a value as an integer or perform mathematical operations on a value stored as a string. The str() method is used to convert an integer to a string.<\/p>\n\n\n\n<p>Now you\u2019re ready to convert strings to integers in Python like an expert!<br><\/p>\n","protected":false},"excerpt":{"rendered":"How to Convert Python String to Int:To convert a string to integer in Python, use the int() function. This function takes two parameters: the initial string and the optional base to represent the data. Use the syntax print(int(\"STR\")) to return the str as an int, or integer. How to Convert Python Int to String:To convert&hellip;","protected":false},"author":240,"featured_media":15065,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-12278","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"1","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 String to Int() and Int to String Tutorial | Career Karma<\/title>\n<meta name=\"description\" content=\"The Python int method is used to convert a string to an integer. Learn how to use the int and str method on Career Karma.\" \/>\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-string-to-int\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python String to Int() and Int to String Tutorial: Type Conversion in Python\" \/>\n<meta property=\"og:description\" content=\"The Python int method is used to convert a string to an integer. Learn how to use the int and str method on Career Karma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/\" \/>\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-07-21T00:00:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:55:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/python-string-to-int.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"560\" \/>\n\t<meta property=\"og:image:height\" content=\"315\" \/>\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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python String to Int() and Int to String Tutorial: Type Conversion in Python\",\"datePublished\":\"2020-07-21T00:00:36+00:00\",\"dateModified\":\"2023-12-01T11:55:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/\"},\"wordCount\":1201,\"commentCount\":2,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/python-string-to-int.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/\",\"name\":\"Python String to Int() and Int to String Tutorial | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/python-string-to-int.jpg\",\"datePublished\":\"2020-07-21T00:00:36+00:00\",\"dateModified\":\"2023-12-01T11:55:30+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The Python int method is used to convert a string to an integer. Learn how to use the int and str method on Career Karma.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/python-string-to-int.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/python-string-to-int.jpg\",\"width\":560,\"height\":315,\"caption\":\"Python String to Int\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#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 String to Int() and Int to String Tutorial: Type Conversion in Python\"}]},{\"@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 String to Int() and Int to String Tutorial | Career Karma","description":"The Python int method is used to convert a string to an integer. Learn how to use the int and str method on Career Karma.","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-string-to-int\/","og_locale":"en_US","og_type":"article","og_title":"Python String to Int() and Int to String Tutorial: Type Conversion in Python","og_description":"The Python int method is used to convert a string to an integer. Learn how to use the int and str method on Career Karma.","og_url":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-07-21T00:00:36+00:00","article_modified_time":"2023-12-01T11:55:30+00:00","og_image":[{"width":560,"height":315,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/python-string-to-int.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python String to Int() and Int to String Tutorial: Type Conversion in Python","datePublished":"2020-07-21T00:00:36+00:00","dateModified":"2023-12-01T11:55:30+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/"},"wordCount":1201,"commentCount":2,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/python-string-to-int.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-string-to-int\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/","url":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/","name":"Python String to Int() and Int to String Tutorial | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/python-string-to-int.jpg","datePublished":"2020-07-21T00:00:36+00:00","dateModified":"2023-12-01T11:55:30+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The Python int method is used to convert a string to an integer. Learn how to use the int and str method on Career Karma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-string-to-int\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/python-string-to-int.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/python-string-to-int.jpg","width":560,"height":315,"caption":"Python String to Int"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-string-to-int\/#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 String to Int() and Int to String Tutorial: Type Conversion in Python"}]},{"@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\/12278","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=12278"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12278\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/15065"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=12278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=12278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=12278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}