我想要發生的情況是,如果控制檯打印某些內容的數量超過了500,但是現在它計算的是該數字不是數值的多少。如何計算一定數量而不是實際數量的長度?
print ("What Is The Current Distance In Meters?")
distance = input()
if len (distance) >= 500:
(print) ("Thanks")
我想要發生的情況是,如果控制檯打印某些內容的數量超過了500,但是現在它計算的是該數字不是數值的多少。如何計算一定數量而不是實際數量的長度?
print ("What Is The Current Distance In Meters?")
distance = input()
if len (distance) >= 500:
(print) ("Thanks")
您需要先距離轉換成一個數字,然後用比運營商>
更大,所以你的代碼變成:
print ("What Is The Current Distance In Meters?")
distance = input()
if int(distance) > 500 :
print ("Thanks")
希望我幫助!
非常感謝你<3 –
input()
始終是一個字符串 - 你可能想distance = int(input())
'INT(距離)'? –
爲什麼你在'print'中加括號? – user2357112