Object2 Python _ isinstance로 타입을 체크하자. 어떤 객체가 무슨 타입인지를 알려면 type() 메서드를 활용하면 됩니다. 하지만 어떤 타입이 맞는지 참/거짓으로 체크만 하고 싶다면 isinstance()를 활용할 수 있습니다. 사용법은 간단합니다. isinstance 메서드에 첫 번째 인자로 해당 객체를, 두번째 인자로 체크하고 싶은 타입을 넣어주면 됩니다. def 체크_문자열(객체): return isinstance(객체, str) print(체크_문자열('문자')) # >>> True print(체크_문자열(123)) # >>> False 문자열을 넣었을 때는 True, 숫자를 넣었을 때는 False를 반환합니다. def 체크_리스트(객체): return isinstance(객체, list) print(체크_리스트('문자')) # >>> Fals.. 2022. 3. 30. Who likes it? Description: You probably know the "like" system from Facebook and other pages. People can "like" blog posts, pictures or other items. We want to create the text that should be displayed next to such an item. Implement the function which takes an array containing the names of people that like an item. It must return the display text as shown in the examples: [] --> "no one likes this" ["Peter"] .. 2022. 3. 7. 이전 1 다음