{"id":19043,"date":"2021-08-29T15:13:33","date_gmt":"2021-08-29T09:43:33","guid":{"rendered":"https:\/\/python-programs.com\/?p=19043"},"modified":"2021-11-22T18:37:08","modified_gmt":"2021-11-22T13:07:08","slug":"python-program-to-check-duck-number","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-check-duck-number\/","title":{"rendered":"Python Program to Check Duck Number"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Convert Decimal Number to Binary String using Recursion<\/a>
\nDuck Number:<\/strong><\/p>\n

A Duck number is one that has a zero in between or at the end of a given number.<\/p>\n

For Example:<\/p>\n

Let Number = 2300<\/p>\n

It is a Duck number because it has zeros to the end.<\/p>\n

Number= 00054<\/p>\n

It is not a Duck number because it has zeros at the beginning. The actual value of a number is 54 if those zeros are removed.<\/p>\n

Given a number and the task is to check if the given number is a Duck Number or not.<\/p>\n

lstrip() Method in Python:<\/strong><\/p>\n

The lstrip() method returns a string copy with the leading characters removed (based on the string argument passed).<\/p>\n

Based on the argument, lstrip() removes characters from the left (a string specifying the set of characters to be removed).<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 320045<\/pre>\n

Output:<\/strong><\/p>\n

The above given number { 320045 } is a Duck number<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 1400<\/pre>\n

Output:<\/strong><\/p>\n

The above given number { 1400 } is a Duck number<\/pre>\n

Program to Check Duck Number in Python<\/h2>\n

Below are the ways to check if the given number is a Duck Number or not:<\/p>\n