ex02 ok
This commit is contained in:
18
d00/ex02/find_ft_type.py
Normal file
18
d00/ex02/find_ft_type.py
Normal file
@@ -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
|
||||
14
d00/ex02/tester.py
Normal file
14
d00/ex02/tester.py
Normal file
@@ -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))
|
||||
Reference in New Issue
Block a user