if文を作成して、入力された数値がintかどうかをチェックしたいと思います。私は入力を分割しているときに何をすべきかわかりません(3dと3を変数に、dを変数にします)。あなたが手紙を入力するとエラーメッセージが出ないようにしたい。ここで数値がint型かstr型かをチェックする方法
は、問題のコードです:
while directionloop ==0:
while DAmountLoop==0:
direction=input('How do you want to move? Your answer should look like this 4u, this moves you up 4: ')
directiondirection=str(direction[1])
directionamount=(direction[0])
if type(directionamount) != int:
print('You need to enter a number for the amount you want to move')
elif type(directionamount) == int:
directionamount=int(direction[0])
DAmountLoop=1
"input"を使用すると、入力したデータタイプに関係なく常に「文字列」表現が得られます – kmario23