diff --git a/d00/ex02/find_ft_type.py b/d00/ex02/find_ft_type.py new file mode 100644 index 0000000..8b119da --- /dev/null +++ b/d00/ex02/find_ft_type.py @@ -0,0 +1,18 @@ +def all_thing_is_obj(object: any) -> int: + # https://docs.python.org/3.10/library/functions.html?highlight=type#type + ofType = type(object) + + match object: + case list(): + print("List : ", ofType) + case tuple(): + print("Tuple : ", ofType) + case set(): + print("Set : ", ofType) + case dict(): + print("Dict : ", ofType) + case str(): + print(object + " is in the kitchen : ", ofType) + case _: + print("Type not found") + return 42 \ No newline at end of file diff --git a/d00/ex02/tester.py b/d00/ex02/tester.py new file mode 100644 index 0000000..0202ab0 --- /dev/null +++ b/d00/ex02/tester.py @@ -0,0 +1,14 @@ +from find_ft_type import all_thing_is_obj + +ft_list = ["Hello", "tata!"] +ft_tuple = ("Hello", "toto!") +ft_set = {"Hello", "tutu!"} +ft_dict = {"Hello" : "titi!"} + +all_thing_is_obj(ft_list) +all_thing_is_obj(ft_tuple) +all_thing_is_obj(ft_set) +all_thing_is_obj(ft_dict) +all_thing_is_obj("Brian") +all_thing_is_obj("Toto") +print(all_thing_is_obj(10)) \ No newline at end of file