Evens and Odds
Write a program to count even and odd numbers in given range [M, N]. Both M, N are inclusive in [M, N].Input
The first line of the input will be an integer(M).
The Second line of the input will be an integer(N).Output
The first line of output should be a number of odds count.
The second line of output should be a number of even counts.
M = int(input("Enter M: "))
N = int(input("Enter N: "))
if M >= N:
print("Wrong range!")
else:
print("Odds: ", end = "")
for i in range(M, N+1):
if i % 2 == 1:
print(i, end = " ")
print("")
print ("Even: ", end = "")
for i in range(M, N+1):
if i % 2 == 0:
print(i, end = " ")
print("")
Comments
Leave a comment