- 3
Check a number
how to check that a number is in a given input
8 ответов
+ 2
Calvin Thomas isdigit() function will go on with it
+ 1
https://www.geeksforgeeks.org/program-check-input-integer-string/
# hope this helps you
+ 1
in addition to lisa, making two variables assigned with 2 inputs would be better.
Ex:
a = input()
b = input()
if b in a:
print("True")
else:
print("False")
+ 1
lisa The 'in' operator works only with strings.
+ 1
Somasundaram Puspagaran
Use try except block:
try:
x = int(input())
print (x)
except:
print ("Enter number only")
0
i = input()
num = 7 # keep any number here the number you want to check.
if num in i:
print("True")
else:
print("False")
0
2 Inputs work too, since 'in' operator works only for strings including inputs.
0
digit=5
inpu = 1256
print(str(digit) in str(inpu))
#True
#------------------------------------------------#
num = 5
inpu = "1256"
print(str(digit) in str(inpu))
#True