Reputation: 1
Distance = input("How far are you from the spacecraft in meters? (full positive numbers) \n")
number = Distance.isdigit()
while number == False:
print ("Please enter a number or full number")
Distance = input("How far are you from the spacecraft in meters? (full positive numbers) \n")
number = Distance.isdigit()
while Distance < 600:
print ("Please move back further from the space craft! \n")
Distance = input("How far are you from the spacecraft in meters? (full positive numbers) \n")
So I am trying to compare a string to a integer but I'm not sure how to fix that with out breaking this part
number = Distance.isdigit() while number == False:
Upvotes: 0
Views: 114
Reputation: 2257
I think you can use this.
def is_digit(Distance):
try:
if int(Distance) & int(Distance) >0:
return True
return False
except ValueError:
return False
Upvotes: 3