Apr-06-2020, 04:37 PM
class Cars: def __init__(self,brand,model,year,amount,daily_price): self.brand=brand self.model=model self.year=year self.amount=amount self.daily_price=daily_price car1=Cars("BMW","3.18","2018","8","140") car2=Cars("Mercedes","A180","2019","4","120") car3=Cars("BMW","5.20","2017","3","210") car4=Cars("Volkswagen","Passat","2014","3","120") list=("Our car brands:","BMW","Mercedes","Volkswagen") for i in list: print(i) def write_selection(): car_name=input("Enter your selection:") selection="" list_selection=Cars try: while selection!="exit": selection=input("Enter a new brand:") except: pass write_selection()##The program should ask the user for entering a valid option in our brand list. If the user enter a non-valid option as brand, it should continue forever until a valid option or if s/he enter 'exit'. If the user input is 'exit' display nothing for details.
I did first parts of the problem but I couldn't this part can you help??
Our car brands:
BMW
Mercedes
Volkswagen
Enter your selection:BMW
Enter a new brand:Hyundai
##Its output is this but I don't want this.