+ 2
What should be the range in this program??
6 Respuestas
+ 4
Hi Jyoti do you know what is an integer?
If you know that then it would be easy for you to fill that range. Anyways for any 'n' the range checks from 0 to n-1. So that will not help you find if a number is an integer or not. You can just check whether the entered number is in the given range or not.
+ 3
The way I would implement it
y=input('Enter a number :')
j=0
for i in y:
if ord(i)>=48 and ord(i)<58:
j+=1
continue
print("Number is non integer")
break
if j==len(y):
print("Number is integer")
+ 2
U r checking number is integer or not.
But u r taking only integer input in program.
y=int(input('Enter a number :'))
So in your program result always be integer.
Or error
You may check the value is int using these lines.
y=eval(input('Enter a number :'))
print(isinstance(y,int))
+ 1
Thanks
0
Thnks everyone