Advertisement
Programmin-in-Python

Segregating and counting the even and odd digits of a number

Feb 19th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. def num_counter():
  2.     even, odd = 0, 0
  3.     num = input('Enter any Number : ')
  4.  
  5.     for i in num:
  6.         if int(i)%2 == 0:
  7.             even += 1
  8.         else:
  9.             odd += 1
  10.  
  11.     print(f"The number of EVEN digits in {num} : {even}")
  12.     print(f"The number of ODD digits in {num} : {odd}")
  13.  
  14. num_counter()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement