import sys clients = '' def add_client(client_name): global clients if client_name.upper() not in clients.upper(): clients += client_name _add_coma() else: print("The client already exist!!") def update_client(client_name,name_update): global clients if client_name.upper() in clients.upper(): clients = clients.replace(client_name,name_update) else: print("The client not exist!!") def search_client(client_name): global clients client_list = clients.split(',') for client in client_list: if client != client_name: continue else: return True def delete_client(client_name): global clients if client_name.upper() in clients.upper(): clients = clients.replace(client_name+',','') else: print("The client not exist!!") def _add_coma(): global clients clients += ',' def list_client(): global clients print(clients) def _get_client_name(): client_name = None while not client_name: client_name = input("What's client Name? ") if client_name == 'exit': client_name == None break if not client_name: sys.exit() return client_name def _print_welcome(): mesaje =""" WELCOME TO PLATZI VENTAS '*'*50 What would you lke to do today? [C] Create Client [L] List Client [D] Delete Client [U] Update Client [S] Search Client [E] Salir : """ option = input(mesaje) return option if __name__ == "__main__": active = True while active: option = _print_welcome() if option == 'L' or option == 'l': list_client() elif option == 'C' or option == 'c': name = _get_client_name() add_client(name) list_client() elif option == 'S' or option == 's': name = _get_client_name() found = search_client(name) if found: print('The client is in the client\'s list') else: print('The client: {} is not in our client\'s list'.format(name)) elif option == 'U' or option == 'u': name = _get_client_name() name_update = input("What's name to update? ") update_client(name,name_update) list_client() elif option == 'D' or option == 'd': name = _get_client_name() delete_client(name) list_client() elif option == 'E' or option == 'e': active = False