Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python program to print odd numbers in a List

# Python program to print odd Numbers in a List
  
# list of numbers
list1 = [10, 21, 4, 45, 66, 93]
  
# iterating each number in list
for num in list1:
      
    # checking condition
    if num % 2 != 0:
       print(num, end = " ")
Comment

Python program to print even numbers in a list

#Python program to print
#even numbers in a list using recursion
def evennumbers(list, n=0):
    #base case
    if n==len(list):
        exit()
    if list[n]%2==0:
        print(list[n], end=" ")
    #calling function recursively
    evennumbers(list, n+1)
list1 = [10, 21, 4, 45, 66, 93]
print("Even numbers in the list:", end=" ")
evennumbers(list1)
#this code is contributed by Shivesh Kumar Dwivedi
Comment

Python program to print even numbers in a list

# Python program to print Even Numbers in a List
 
# list of numbers
list1 = [10, 21, 4, 45, 66, 93]
 
# iterating each number in list
for num in list1:
 
    # checking condition
    if num % 2 == 0:
        print(num, end=" ")
Comment

PREVIOUS NEXT
Code Example
Python :: pygame get keypress code 
Python :: _ variable in python 
Python :: Making a txt file then write 
Python :: Get Time from timestamp in python 
Python :: python initialize dict with empty list values 
Python :: python 3.7 download for windows 7 32-bit 
Python :: python recursively merge dictionaries 
Python :: discord python tts 
Python :: finding odd even python 
Python :: colors in scatter plot python 
Python :: import python script from another directory 
Python :: audioplayer python 
Python :: getters and setters in python 
Python :: deep copy a dataframe 
Python :: is python good for web development 
Python :: python import timezone 
Python :: python plot two lines with different y axis 
Python :: python loop back to start 
Python :: edit pandas row value 
Python :: print python float precision 
Python :: python for/else 
Python :: how to concatenate a string with int in python 
Python :: python message from teams 
Python :: Find Files With a Certain Extension in the Directory and Its Subdirectories in Python 
Python :: file manage py line 17 from exc django 
Python :: python split string to sentences 
Python :: length of string python 
Python :: boto3.resource python 
Python :: python combine two lists into matrix 
Python :: udp server python 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =