GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • w3resource
  • Front End
  • HTML
  • CSS
  • JavaScript
  • HTML5
  • Schema.org
  • php.js
  • Twitter Bootstrap
  • Responsive Web Design tutorial
  • Zurb Foundation 3 tutorials
  • Pure CSS
  • HTML5 Canvas
  • JavaScript Course

This view

  • Original page
  • New address

GeezerVison is showing www.w3resource.com — Python: Find numbers divisible by nineteen or thirteen from a list of numbers using Lambda - w3resource

Python: Find numbers divisible by nineteen or thirteen from a list of numbers using Lambda

Last update on July 12 2025 13:05:18 (UTC/GMT +8 hours)


17. Divisible by 19 or 13 Lambda

Write a Python program to find numbers divisible by nineteen or thirteen from a list of numbers using Lambda.

Sample Solution:

Python Code :

# Create a list 'nums' containing integers
nums = [19, 65, 57, 39, 152, 639, 121, 44, 90, 190]

# Display a message indicating that the following output will show the original list
print("Orginal list:")
print(nums)  # Print the contents of the 'nums' list

# Use the 'filter()' function with a lambda function to filter numbers divisible by 19 or 13
# Filter elements from 'nums' using the lambda function to keep numbers divisible by 19 or 13
result = list(filter(lambda x: (x % 19 == 0 or x % 13 == 0), nums))

# Display numbers from the original list that are divisible by 19 or 13
print("\nNumbers of the above list divisible by nineteen or thirteen:")
print(result)  # Print the filtered 'result' list 

Sample Output:

Orginal list:
[19, 65, 57, 39, 152, 639, 121, 44, 90, 190]

Numbers of the above list divisible by nineteen or thirteen:
[19, 65, 57, 39, 152, 190]

For more Practice: Solve these Related Problems:

  • Write a Python program to find numbers divisible by both nineteen and thirteen using lambda.
  • Write a Python program to filter numbers that are divisible by nineteen but not by thirteen using lambda.
  • Write a Python program to identify numbers divisible by the sum of nineteen and thirteen using lambda.
  • Write a Python program to count the number of elements in a list that are divisible by either nineteen or thirteen using lambda.

Go to:

  • Python Lambda Exercises Home ↩
  • Python Exercises Home ↩

Previous: Write a Python program to find the second lowest grade of any student(s) from the given names and grades of each student using lists and lambda.
Next: Write a Python program to find palindromes in a given list of strings using Lambda.

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.


  • Daily Coding Challenges & Projects
  • Weekly Trends and Language Statistics



You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.