{"id":6117,"date":"2026-01-24T12:08:14","date_gmt":"2026-01-24T12:08:14","guid":{"rendered":"https:\/\/www.askpython.com\/?p=6117"},"modified":"2026-01-25T14:55:34","modified_gmt":"2026-01-25T14:55:34","slug":"python-list-comprehension","status":"publish","type":"post","link":"https:\/\/www.askpython.com\/python\/list\/python-list-comprehension","title":{"rendered":"List Comprehension Python: Write Concise Code"},"content":{"rendered":"<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Basic list comprehension syntax\nnew_list = &#x5B;expression for item in iterable]\n\n# Example: Square each number in a list\nnumbers = &#x5B;1, 2, 3, 4, 5]\nsquares = &#x5B;num ** 2 for num in numbers]\nprint(squares)  # Output: &#x5B;1, 4, 9, 16, 25]\n\n<\/pre><\/div>\n\n\n<p>List comprehension python provides a single-line mechanism to construct new lists by applying operations to each element in an existing iterable. The syntax consists of square brackets containing an expression, followed by a for clause that iterates through a source iterable. This approach replaces multi-line for loops with compact, readable code that executes faster due to Python&#8217;s internal optimizations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding the basic structure of list comprehension<\/h2>\n\n\n\n<p>The fundamental pattern follows a specific order: the transformation expression appears first, then the for keyword with a variable name, followed by the in keyword and the source iterable. Python evaluates this structure from right to left, iterating through each item in the source and applying the expression to produce output values.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Breaking down the components\nfruits = &#x5B;&#039;apple&#039;, &#039;banana&#039;, &#039;cherry&#039;]\nuppercase_fruits = &#x5B;fruit.upper() for fruit in fruits]\n# Expression: fruit.upper()\n# Variable: fruit\n# Iterable: fruits\n# Result: &#x5B;&#039;APPLE&#039;, &#039;BANANA&#039;, &#039;CHERRY&#039;]\n\n<\/pre><\/div>\n\n\n<p>The expression component accepts any valid Python operation, from simple attribute access to complex function calls. The variable serves as a placeholder representing each element during iteration. The iterable can be any Python object that supports iteration, including lists, tuples, strings, ranges, or generator expressions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating lists with conditional filtering<\/h2>\n\n\n\n<p>List comprehension python supports conditional logic through an optional if clause placed after the for statement. This filter evaluates each item before including it in the output list, processing only elements that satisfy the specified condition.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Filter even numbers from a range\nnumbers = range(20)\neven_numbers = &#x5B;num for num in numbers if num % 2 == 0]\nprint(even_numbers)  # Output: &#x5B;0, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n\n# Extract words longer than 4 characters\nwords = &#x5B;&#039;cat&#039;, &#039;elephant&#039;, &#039;dog&#039;, &#039;hippopotamus&#039;, &#039;ant&#039;]\nlong_words = &#x5B;word for word in words if len(word) &gt; 4]\nprint(long_words)  # Output: &#x5B;&#039;elephant&#039;, &#039;hippopotamus&#039;]\n\n<\/pre><\/div>\n\n\n<p>The condition executes after the iteration variable receives each value but before the expression processes it. Only items returning True from the conditional check proceed to the expression evaluation stage. This filtering happens inline without requiring separate filter() function calls or intermediate variables.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Applying transformation and filtering simultaneously<\/h2>\n\n\n\n<p>Complex list comprehensions combine both transformation and filtering in a single statement. The expression transforms each element while the if clause determines which elements undergo transformation.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Convert strings to integers, filtering out non-numeric values\nmixed_data = &#x5B;&#039;42&#039;, &#039;apple&#039;, &#039;17&#039;, &#039;banana&#039;, &#039;99&#039;, &#039;cherry&#039;]\nnumbers = &#x5B;int(item) for item in mixed_data if item.isdigit()]\nprint(numbers)  # Output: &#x5B;42, 17, 99]\n\n# Square even numbers only\nvalues = &#x5B;1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\neven_squares = &#x5B;num ** 2 for num in values if num % 2 == 0]\nprint(even_squares)  # Output: &#x5B;4, 16, 36, 64, 100]\n\n<\/pre><\/div>\n\n\n<p>The filtering condition precedes the transformation, ensuring Python only applies expensive operations to relevant items. This sequence improves performance when processing large datasets with selective transformations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using if-else expressions in list comprehension<\/h2>\n\n\n\n<p>List comprehension python accommodates ternary conditional expressions within the output expression itself. This pattern differs from filtering because it processes every element but produces different outputs based on conditions.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Classify numbers as even or odd\nnumbers = &#x5B;1, 2, 3, 4, 5, 6]\nclassifications = &#x5B;&#039;even&#039; if num % 2 == 0 else &#039;odd&#039; for num in numbers]\nprint(classifications)  # Output: &#x5B;&#039;odd&#039;, &#039;even&#039;, &#039;odd&#039;, &#039;even&#039;, &#039;odd&#039;, &#039;even&#039;]\n\n# Replace negative numbers with zero\nvalues = &#x5B;5, -3, 8, -1, 12, -7]\nnon_negative = &#x5B;num if num &gt;= 0 else 0 for num in values]\nprint(non_negative)  # Output: &#x5B;5, 0, 8, 0, 12, 0]\n\n<\/pre><\/div>\n\n\n<p>The ternary expression follows the pattern <code>value_if_true if condition else value_if_false<\/code>, appearing before the for clause. This placement distinguishes it from the filter-style if statement that appears after the iteration specification.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Working with nested list comprehensions<\/h2>\n\n\n\n<p>Nested list comprehension python creates multi-dimensional structures or flattens existing ones. The nested comprehensions read left to right, with outer loops appearing first in the sequence.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Create a multiplication table\nmultiplication_table = &#x5B;&#x5B;i * j for j in range(1, 6)] for i in range(1, 6)]\nprint(multiplication_table)\n# Output: &#x5B;&#x5B;1, 2, 3, 4, 5], &#x5B;2, 4, 6, 8, 10], &#x5B;3, 6, 9, 12, 15], &#x5B;4, 8, 12, 16, 20], &#x5B;5, 10, 15, 20, 25]]\n\n# Generate coordinate pairs for a grid\ncoordinates = &#x5B;(x, y) for x in range(3) for y in range(3)]\nprint(coordinates)\n# Output: &#x5B;(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]\n\n<\/pre><\/div>\n\n\n<p>The coordinate example demonstrates how multiple for clauses create a Cartesian product of iterables. Python processes the leftmost for clause first, then iterates through the rightmost clause for each element from the left.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Flattening nested lists with list comprehension<\/h2>\n\n\n\n<p>List comprehension python excels at converting multi-dimensional structures into single-dimension lists. The technique employs two for clauses that iterate through outer and inner levels sequentially.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Flatten a matrix into a single list\nmatrix = &#x5B;&#x5B;1, 2, 3], &#x5B;4, 5, 6], &#x5B;7, 8, 9]]\nflattened = &#x5B;num for row in matrix for num in row]\nprint(flattened)  # Output: &#x5B;1, 2, 3, 4, 5, 6, 7, 8, 9]\n\n# Extract all elements from nested lists of varying lengths\nirregular_nested = &#x5B;&#x5B;10, 20], &#x5B;30], &#x5B;40, 50, 60], &#x5B;70, 80]]\nall_values = &#x5B;item for sublist in irregular_nested for item in sublist]\nprint(all_values)  # Output: &#x5B;10, 20, 30, 40, 50, 60, 70, 80]\n\n<\/pre><\/div>\n\n\n<p>The flattening pattern reads naturally when translated to English: &#8220;for each row in the matrix, for each number in that row, include the number.&#8221; This ordering matches the nested for loop equivalent where the outer loop processes rows before the inner loop processes individual elements.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Combining multiple conditions in list comprehension<\/h2>\n\n\n\n<p>Multiple if clauses function as AND conditions, requiring all conditions to evaluate True before including an element. This pattern replaces complex boolean expressions with readable sequential checks.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Find numbers divisible by both 3 and 5\nnumbers = range(100)\ndivisible_by_both = &#x5B;num for num in numbers if num % 3 == 0 if num % 5 == 0]\nprint(divisible_by_both)  # Output: &#x5B;0, 15, 30, 45, 60, 75, 90]\n\n# Filter strings by multiple criteria\nwords = &#x5B;&#039;Python&#039;, &#039;code&#039;, &#039;programming&#039;, &#039;data&#039;, &#039;analysis&#039;]\nfiltered = &#x5B;word for word in words if len(word) &gt; 4 if word&#x5B;0] in &#039;Pp&#039;]\nprint(filtered)  # Output: &#x5B;&#039;Python&#039;, &#039;programming&#039;]\n\n<\/pre><\/div>\n\n\n<p>Each if clause operates independently, evaluating only items that passed previous conditions. This sequential filtering stops processing items as soon as any condition fails, potentially improving performance over compound boolean expressions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using enumerate with list comprehension<\/h2>\n\n\n\n<p>List comprehension python integrates with enumerate() to access both index positions and values during iteration. This technique proves valuable when creating derived data structures that depend on element positions.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Create tuples of indices and values\nfruits = &#x5B;&#039;apple&#039;, &#039;banana&#039;, &#039;cherry&#039;, &#039;date&#039;]\nindexed_fruits = &#x5B;(index, fruit) for index, fruit in enumerate(fruits)]\nprint(indexed_fruits)\n# Output: &#x5B;(0, &#039;apple&#039;), (1, &#039;banana&#039;), (2, &#039;cherry&#039;), (3, &#039;date&#039;)]\n\n# Filter items based on their position\nnumbers = &#x5B;10, 20, 30, 40, 50]\neven_positioned = &#x5B;num for index, num in enumerate(numbers) if index % 2 == 0]\nprint(even_positioned)  # Output: &#x5B;10, 30, 50]\n\n<\/pre><\/div>\n\n\n<p>The enumerate() function returns tuples containing indices and values, which the for clause unpacks into separate variables. This unpacking enables independent access to both components within the comprehension expression or conditions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Processing strings with list comprehension<\/h2>\n\n\n\n<p>String iteration through list comprehension python treats each character as an individual element. This approach simplifies character-level transformations and filtering operations.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Extract vowels from a string\ntext = &#039;comprehension&#039;\nvowels = &#x5B;char for char in text if char in &#039;aeiou&#039;]\nprint(vowels)  # Output: &#x5B;&#039;o&#039;, &#039;e&#039;, &#039;e&#039;, &#039;i&#039;, &#039;o&#039;]\n\n# Convert characters to ASCII values\nword = &#039;Python&#039;\nascii_values = &#x5B;ord(char) for char in word]\nprint(ascii_values)  # Output: &#x5B;80, 121, 116, 104, 111, 110]\n\n# Remove whitespace and convert to uppercase\nsentence = &#039;  hello world  &#039;\ncleaned = &#x5B;char.upper() for char in sentence if not char.isspace()]\nprint(&#039;&#039;.join(cleaned))  # Output: HELLOWORLD\n\n<\/pre><\/div>\n\n\n<p>String processing combines transformation functions like upper(), lower(), and ord() with filtering conditions that check character properties through methods like isspace(), isdigit(), and isalpha().<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Replacing map and filter functions<\/h2>\n\n\n\n<p>List comprehension python provides a more readable alternative to functional programming constructs like map() and filter(). The comprehension syntax eliminates lambda function requirements while maintaining equivalent functionality.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Traditional map approach\nnumbers = &#x5B;1, 2, 3, 4, 5]\nsquared_map = list(map(lambda x: x ** 2, numbers))\n\n# List comprehension equivalent\nsquared_comp = &#x5B;num ** 2 for num in numbers]\n\n# Traditional filter approach\neven_filter = list(filter(lambda x: x % 2 == 0, numbers))\n\n# List comprehension equivalent\neven_comp = &#x5B;num for num in numbers if num % 2 == 0]\n\n# Combining map and filter\ntransformed = list(map(lambda x: x ** 2, filter(lambda x: x % 2 == 0, numbers)))\n\n# Single list comprehension\ncombined = &#x5B;num ** 2 for num in numbers if num % 2 == 0]\n\n<\/pre><\/div>\n\n\n<p>The comprehension approach maintains better readability because the transformation and filtering logic appear in a natural left-to-right reading order. The map() and filter() combination requires inside-out reading to understand the complete operation sequence.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Working with dictionary items in list comprehension<\/h2>\n\n\n\n<p>List comprehension python processes dictionary items through the items() method, enabling simultaneous access to keys and values. This technique supports creating filtered or transformed lists from dictionary data.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Extract values meeting specific criteria\nprices = {&#039;apple&#039;: 1.20, &#039;banana&#039;: 0.50, &#039;cherry&#039;: 2.50, &#039;date&#039;: 3.00}\nexpensive_fruits = &#x5B;fruit for fruit, price in prices.items() if price &gt; 1.00]\nprint(expensive_fruits)  # Output: &#x5B;&#039;apple&#039;, &#039;cherry&#039;, &#039;date&#039;]\n\n# Create formatted strings from dictionary data\nscores = {&#039;Alice&#039;: 95, &#039;Bob&#039;: 87, &#039;Charlie&#039;: 92}\nreports = &#x5B;f&quot;{name}: {score}%&quot; for name, score in scores.items()]\nprint(reports)  # Output: &#x5B;&#039;Alice: 95%&#039;, &#039;Bob: 87%&#039;, &#039;Charlie: 92%&#039;]\n\n<\/pre><\/div>\n\n\n<p>The items() method returns tuples of key-value pairs, which the comprehension unpacks into separate variables. This unpacking pattern extends to any iterable returning tuple-like structures.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Performance characteristics of list comprehension<\/h2>\n\n\n\n<p>List comprehension python executes faster than equivalent for loops because Python optimizes the comprehension syntax at the bytecode level. The interpreter recognizes the pattern and applies specific optimizations unavailable to general loop constructs.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport timeit\n\n# For loop approach\ndef with_for_loop():\n    result = &#x5B;]\n    for i in range(1000):\n        result.append(i ** 2)\n    return result\n\n# List comprehension approach\ndef with_comprehension():\n    return &#x5B;i ** 2 for i in range(1000)]\n\n# Timing comparison\nloop_time = timeit.timeit(with_for_loop, number=10000)\ncomp_time = timeit.timeit(with_comprehension, number=10000)\n\nprint(f&quot;For loop: {loop_time:.4f} seconds&quot;)\nprint(f&quot;Comprehension: {comp_time:.4f} seconds&quot;)\n\n<\/pre><\/div>\n\n\n<p>The performance advantage stems from reduced function call overhead and optimized memory allocation patterns. List comprehensions pre-allocate memory for the entire result when possible, avoiding incremental reallocation as lists grow.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When to avoid list comprehension<\/h2>\n\n\n\n<p>Complex nested comprehensions or deeply nested conditions reduce code readability despite syntactic brevity. Traditional for loops provide clearer logic flow when comprehensions exceed comfortable single-line length.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Avoid: Complex nested comprehension\nresult = &#x5B;&#x5B;item.upper() if len(item) &gt; 3 else item.lower() \n           for item in sublist if item.isalpha()] \n          for sublist in nested_list if len(sublist) &gt; 2]\n\n# Prefer: Explicit for loops for complex logic\nresult = &#x5B;]\nfor sublist in nested_list:\n    if len(sublist) &gt; 2:\n        filtered = &#x5B;]\n        for item in sublist:\n            if item.isalpha():\n                filtered.append(item.upper() if len(item) &gt; 3 else item.lower())\n        result.append(filtered)\n\n<\/pre><\/div>\n\n\n<p>Side effects within comprehensions create unexpected behavior because comprehensions evaluate eagerly and cannot guarantee evaluation order for complex expressions. Functions with side effects belong in explicit loop structures where execution sequence remains clear.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating sets and dictionaries with comprehension<\/h2>\n\n\n\n<p>Python extends the comprehension syntax beyond lists to sets and dictionaries. Set comprehension eliminates duplicates automatically while dictionary comprehension creates key-value mappings.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Set comprehension removes duplicates\nnumbers = &#x5B;1, 2, 2, 3, 3, 3, 4, 4, 4, 4]\nunique_squares = {num ** 2 for num in numbers}\nprint(unique_squares)  # Output: {16, 1, 4, 9}\n\n# Dictionary comprehension creates mappings\nwords = &#x5B;&#039;apple&#039;, &#039;banana&#039;, &#039;cherry&#039;]\nword_lengths = {word: len(word) for word in words}\nprint(word_lengths)  # Output: {&#039;apple&#039;: 5, &#039;banana&#039;: 6, &#039;cherry&#039;: 6}\n\n# Invert a dictionary\noriginal = {&#039;a&#039;: 1, &#039;b&#039;: 2, &#039;c&#039;: 3}\ninverted = {value: key for key, value in original.items()}\nprint(inverted)  # Output: {1: &#039;a&#039;, 2: &#039;b&#039;, 3: &#039;c&#039;}\n\n<\/pre><\/div>\n\n\n<p>Set comprehension uses curly braces without colons, while dictionary comprehension requires key-value pairs separated by colons. Both follow the same filtering and transformation patterns as list comprehension.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Practical applications of list comprehension<\/h2>\n\n\n\n<p>List comprehension python solves common data processing tasks with minimal code. These patterns appear frequently in data analysis, file processing, and transformation pipelines.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Parse CSV-style data\ncsv_lines = &#x5B;&#039;name,age,city&#039;, &#039;Alice,30,NYC&#039;, &#039;Bob,25,LA&#039;, &#039;Charlie,35,Chicago&#039;]\ndata = &#x5B;line.split(&#039;,&#039;) for line in csv_lines&#x5B;1:]]\nprint(data)\n# Output: &#x5B;&#x5B;&#039;Alice&#039;, &#039;30&#039;, &#039;NYC&#039;], &#x5B;&#039;Bob&#039;, &#039;25&#039;, &#039;LA&#039;], &#x5B;&#039;Charlie&#039;, &#039;35&#039;, &#039;Chicago&#039;]]\n\n# Extract file extensions\nfilenames = &#x5B;&#039;document.pdf&#039;, &#039;image.jpg&#039;, &#039;script.py&#039;, &#039;data.csv&#039;]\nextensions = &#x5B;name.split(&#039;.&#039;)&#x5B;-1] for name in filenames]\nprint(extensions)  # Output: &#x5B;&#039;pdf&#039;, &#039;jpg&#039;, &#039;py&#039;, &#039;csv&#039;]\n\n# Normalize data to a specific range\nvalues = &#x5B;10, 20, 30, 40, 50]\nmin_val, max_val = min(values), max(values)\nnormalized = &#x5B;(x - min_val) \/ (max_val - min_val) for x in values]\nprint(normalized)  # Output: &#x5B;0.0, 0.25, 0.5, 0.75, 1.0]\n\n# Filter and clean user input\ninputs = &#x5B;&#039;  hello  &#039;, &#039;&#039;, &#039;  world  &#039;, &#039;   &#039;, &#039;python&#039;]\ncleaned = &#x5B;text.strip() for text in inputs if text.strip()]\nprint(cleaned)  # Output: &#x5B;&#039;hello&#039;, &#039;world&#039;, &#039;python&#039;]\n\n<\/pre><\/div>\n\n\n<p>These patterns demonstrate how list comprehension python combines filtering, transformation, and extraction operations into single, expressive statements that communicate intent clearly while maintaining compact syntax.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>List comprehension python provides a single-line mechanism to construct new lists by applying operations to each element in an existing iterable. The syntax consists of square brackets containing an expression, followed by a for clause that iterates through a source iterable. This approach replaces multi-line for loops with compact, readable code that executes faster due [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":65726,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-6117","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-list"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts\/6117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/comments?post=6117"}],"version-history":[{"count":0,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts\/6117\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/media\/65726"}],"wp:attachment":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/media?parent=6117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/categories?post=6117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/tags?post=6117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}