How to input our values and do odd or even | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to input our values and do odd or even

Need odd or even program which user must provide the value in place of input

1st Mar 2017, 10:39 AM
gokul
2 Answers
0
number = user input thingy... if(number % 2 ==0): return true else: return false:
1st Mar 2017, 10:52 AM
Niels Spiljard
Niels Spiljard - avatar
0
num = input('Please give me a number: ') while(not num.isdigit()): num = input('Give me a NUMBER: ') result = 'even' if int(num) % 2 == 0 else 'odd' print('It is ' + result + '.') I corrected a typo. Thanks Mr. StarLoad.
1st Mar 2017, 11:10 AM
Twelfty
Twelfty - avatar