Click here to Skip to main content
15,900,907 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
input a number and check whether the thousands place is odd or even ??


What I have tried:

n = int(input())
 
th = n%10000
th_num = th // 1000
if (th_num%2 == 0): 
  print('the thousands place in given number{} is even'.format(n))
else:
  print("the thousands place in given number {} is odd".format(n))
Posted
Updated 22-Sep-21 21:41pm

1 solution

Try
Python
n = int(input())
 
th = n%10000
th_num = th // 1000
th_num = n // 1000
if (th_num%2 == 0): 
  print('the thousands place in given number{} is even'.format(n))
else:
  print("the thousands place in given number {} is odd".format(n))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900