Category: New Python tutorial

python tutorials and learn python

Created with Sketch.

Python Dictionary Comprehension

Python Dictionary Comprehension Summary: in this tutorial, you’ll learn about Python dictionary comprehension to transform or filter items in a dictionary. Introduction to Python dictionary comprehension A dictionary comprehension allows you to run a for loop on a dictionary and do something on each item like transforming or filtering, and returns a new dictionary. Unlike…
Read more

Python Dictionary

Python Dictionary Summary: in this tutorial, you’ll learn about Python Dictionary that allows you to organize related information. Introduction to the Python Dictionary type A Python dictionary is a collection of key-value pairs where each key is associated with a value. A value in the key-value pair can be a number, a string, a list,…
Read more

Python List Comprehensions

Python List Comprehensions Summary: in this tutorial, you’ll learn about Python List comprehensions that allow you to create a new list from an existing one. Introduction to Python list comprehensions In programming, you often need to transform elements of a list and returns a new list. For example, suppose that you have a list of…
Read more

How to Use the Python Reduce() function to Reduce a List into a Single Value

How to Use the Python Reduce() function to Reduce a List into a Single Value Summary: in this tutorial, you’ll learn how to use the Python reduce() function to process a list. Reducing a list Sometimes, you want to reduce a list to a single value. For example, suppose that you have a list of…
Read more

How to Filter List Elements in Python

How to Filter List Elements in Python Summary: in this tutorial, you’ll learn how to filter list elements by using the built-in Python filter() function. Introduction to Python filter() function Sometimes, you need to iterate over elements of a list and select some of them based on specified criteria. Suppose that you have the following…
Read more

How to Transform List Elements with Python map() Function

How to Transform List Elements with Python map() Function Summary: in this tutorial, you’ll learn how to use the Python map() function with lists. Introduction to the Python map() function When working with a list (or a tuple), you often need to transform the elements of the list and return a new list that contains…
Read more

Python Iterables

Python Iterables Summary: in this tutorial, you’ll learn about the Python iterables and iterators. Introduction to Python iterables In Python, an iterable is an object that includes zero, one, or many elements. An iterable has the ability to return its elements one at a time. Because of this feature, you can use a for loop…
Read more

How to Find the Index of an Element in a List

How to Find the Index of an Element in a List   Summary: in this tutorial, you’ll learn how to find the index of an element in a list. To find the index of an element in a list, you use the index() function. The following example defines a list of cities and uses the…
Read more

How to Use a For Loop to Iterate over a List

How to Use a For Loop to Iterate over a List Summary: in this tutorial, you’ll learn how to use the Python for loop to iterate over a list in Python. Using Python for loop to iterate over a list To iterate over a list, you use the for loop statement as follows: for item…
Read more

How to Unpack a List in Python

How to Unpack a List in Python Summary: in this tutorial, you’ll learn how to unpack a list in Python to make your code more concise. Introduction to the list unpacking The following example defines a list of strings: colors = [‘red’, ‘blue’, ‘green’] Code language: Python (python) To assign the first, second, and third…
Read more