What do you think about this code? Do you have some advices and remarks for me about them? I have started learning python recently.
types = { "str": str, "int": int, "float": float, "complex": complex } def my_input(kind, msg, msg_wrong, detail): """ Add-in for input(). Performs validation of the data entered. :param kind: data type. The keys of the dictionary types. If an error occurs, a str is expected. :param msg: a welcome message, such as "Enter a number -> " :param msg_wrong: own message in case of error :param detail: detailed error description (True or False) :return: entered value with type kind """ method = types.get(kind, str) while True: try: value = method(input(msg)) break except ValueError as e: print(msg_wrong, detail * str(e)) return value msg = "-> " msg_wrong = "Error" print(my_input("int", msg, msg_wrong, False)) print(my_input("hello", msg, msg_wrong, True)) # wrong type, will str print(my_input("complex", msg, msg_wrong, True)) """ -> hi Error -> 15 15 -> some text some text -> some text 2 Error complex() arg is a malformed string -> 4-j (4-1j) """