Print odd numbers in a List - Python Last Updated : 14 Apr, 2025 Comments Improve Suggest changes Like Article Like Report We are given a list and our task is to print all the odd numbers from it. This can be done using different methods like a simple loop, list comprehension, or the filter() function. For example, if the input is [1, 2, 3, 4, 5], the output will be [1, 3, 5].Using LoopThe most basic way to print odd numbers in a list is to use a for loop with if conditional check to identify odd numbers. Python a = [10, 15, 23, 42, 37, 51, 62, 5] for i in a: if i % 2 != 0: print(i) Output15 23 37 51 5 Explanation:Loops through list a.For each element i, checks if i % 2 != 0 (i.e., if the number is odd).If the condition is true then print the odd number.Using List ComprehensionList comprehension is similar to the for loop method shown above but offers a more concise way to filter odd numbers from a list. Python a = [10, 15, 23, 42, 37, 51, 62, 5] res = [i for i in a if i % 2 != 0] print(res) Output[15, 23, 37, 51, 5] Explanation: This list comprehension filters all elements in a where i % 2 != 0 (i.e., the number is odd).Using filter() FunctionThe filter() function can also be used to filter out odd numbers. The filter() function applies a function to each item in the iterable and returns a filter object containing only those items where the function returns True. Python a = [10, 15, 23, 42, 37, 51, 62, 5] res = filter(lambda x: x % 2 != 0, a) print(list(res)) Output[15, 23, 37, 51, 5] Explanation:filter() function takes two arguments: a lambda function (lambda x: x % 2 != 0) that checks if the number is odd and the iterable 'a'.The result is a filter object which we convert to a list and print.Related Articles:Python For LoopsList Comprehension in Pythonfilter() in python Comment More infoAdvertise with us Next Article Print odd numbers in a List - Python S Shivam_k Follow Improve Article Tags : Python Python Programs Computer Science Fundamentals DSA python-list Python list-programs +2 More Practice Tags : pythonpython-list Similar Reads Print Numbers in an Interval - Python In this article, we are going to learn how to print numbers within a given interval in Python using simple loops, list comprehensions, and step-based ranges.For Example:Input : i = 2, j = 5Output : 2 3 4 5Input : i = 10, j = 20 , s = 2Output : 10 12 14 16 18 20Letâs explore different methods to prin 2 min read Python program to print positive numbers in a list In this article, we will explore various methods to o print positive numbers in a list. The simplest way to do is by using for loop function. Using LoopThe most basic method for printing positive numbers is to use a for loop to iterate through the list and check each element.Pythona = [-10, 15, 0, 2 1 min read Print all Strong Numbers in Given List - Python The task of printing all Strong numbers from a given list in Python involves iterating through the list and checking each number based on its digit factorial sum. A Strong number is a number whose sum of the factorials of its digits equals the number itself. For example, given a list a = [145, 375, 3 min read Python program to print even numbers in a list Getting even numbers from a list in Python allows you to filter out all numbers that are divisible by 2. For example, given the list a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], you might want to extract the even numbers [2, 4, 6, 8, 10]. There are various efficient methods to extract even numbers from a li 3 min read Print a List of Tuples in Python The task of printing a list of tuples in Python involves displaying the elements of a list where each item is a tuple. A tuple is an ordered collection of elements enclosed in parentheses ( ), while a list is an ordered collection enclosed in square brackets [ ].Using print()print() function is the 2 min read Like