0
 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:

2
  • You can cast: Distance = int(input("blabla")) Commented Jul 6, 2016 at 6:58
  • Try to cast using int(input("somestringinput")) and put it in try-except block to handle it properly when the input string is NAN. Commented Jul 6, 2016 at 7:14

1 Answer 1

3

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 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.