私のプログラムでは、数値でなければならない入力を取りたいと思います。しかし、ユーザーが文字列を入力した場合、プログラムは例外を返します。プログラムが入力文字列は、例えば.Like「を書いてください停止」プログラムのプリントint型以外のものであるならば、int型とするために変換されますPythonハンドリング例外
x=input("Enter a number")
if int(x)=?: #This line should check whether the integer conversion is possible
print("YES")
else #This line should execute if the above conversion couldn't take place
print("Stop writing stuff")