Check selection and compare to list for python -
what trying check input user (using raw_input
) valid option within global list. below have point.
def car(): print "you have selected 'car' option.", print "are sure want?" car_sure = raw_input("enter yes or no: ").lower() if car_sure == "yes": car_brand_choice() elif car_sure == "no": print "you no longer want car. taking select vehicle type." type() else: dead("not valid option. lose vehicle purchasing opportunity.") def car_brand_choice(): print "these car brands can provide you." print "\n".join(car_brands) selection = raw_input("now chance pick brand want. ").title() print "you selected %s\n" %selection print "i have verify selection valid.\n" if selection in car_brands: print "valid selection. may continue." else: print "not valid selection." print "go , select valid brand.\n" car_brand_choice() start()
the verification used select different valid brand or allow user proceed current brand. code formatted in notepad++, hope. don't know how proper formatting show here. i'm sure there similar out there not find it.
well, seems if beginner.
the thing need solve problem in
.
selection = raw_input("now chance pick brand want. ") print "you selected ", selection if selection in car_brands: print "it in list" else: print "its not in list"
add in car_brand_choice()
. further readings, check docs
Comments
Post a Comment