isValid = False while isValid != True: gameStr = raw_input ("Choose a space to place the card: ") #the below makes sure that the input is a digit if gameStr.isdigit() != True: print "Not valid input. Please input a digit." isValid = False continue gameNum = int(gameStr) #the below makes sure input is between 1 and 20 if gameNum <= 0 or gameNum > 20: print "Not a valid space. Please choose again." isValid = False continue #the below makes sure the user does not place a second card in any slot if cardList[gameNum].get_val() != 0: print "Space already taken. Please select a different space." isValid = False continue #if we made it here, it's good isValid = True