map,filter
map과 filter값을 받아오기위해서는
방법이
for루프
list()함수
이 방법밖에 없는건가요??
그리고 map,filter인자에는 list만 들어갈수있나요?? 딕셔너리,set, 튜플등은 안되나요?
답변 1
0
안녕하세요 남기정님,
아래의 예제는 Lambda를 사용해서 쓸수 있는 방법에 대해 보실 수 있습니다.
# Sample list of integers
numbers = [1, 2, 3, 4, 5]
# Using map with a lambda function to square each element
squared_numbers = map(lambda x: x**2, numbers)
# Convert the map object to a list to see the results
result = list(squared_numbers)
# Print the squared numbers
print(result)또한 Dictionary나 Set도 사용 가능합니다.
# Sample dictionary
my_dict = {'a': 1, 'b': 2, 'c': 3}
# Using map with a lambda function to square each value in the dictionary
squared_keys = map(lambda key: my_dict[key]**2, my_dict)
# Convert the map object to a list to see the results
result = list(squared_keys)
# Print the squared keys
print(result)
replit에서 developer frameworks가 안보여요
0
14
2
[업데이트] 파이썬 패키지 부분에서 안되어서 강의 진행 불가
2
69
3
html 읽기 오류
1
93
2
DataFrame groupby 사용관련 질문
1
94
2
pylint shell 사용법
0
72
2
자막오류 수정가능한가요?
0
81
1
복합 조건절 관련 궁금증
0
79
2
49.행맨 프로그램 - 재시도 횟수 관련.
1
76
1
64. 파이썬 입문자가 쉽게 빠지기 쉬운 몇가지 에러(혹은 로직)에 대해 알아보기
0
103
2
Replit UI가 업데이트 되서 강의 진행이 멈췄어요
2
181
3
Replit을 사용해보려고 하는데 영상처럼 진행이 안되네요
3
429
2
실무에서의 제네레이터 함수 사용에 관한 질문입니다.
0
64
2
영상이 소리만 나오고 영상은 안보입니다.
0
87
2
pandas 오류 질문
0
126
2
상속 질문
1
132
2
total을 float으로 바꾸신 이유
0
201
2
섹션2 ["환경 vs. 설정 vs. 구성"] 강의 자막 문의
0
143
1
파이썬 data insert to table
0
223
2
파이썬 Class Method 질문
0
156
2
timeit 쓸 때는 만들었던 함수를 재사용 할 수는 없는지?
0
131
2
__repr__ 와 __str__ 차이점?
0
206
2
class method vs static method
0
275
2
Type hint 문법의 Type Checking이 강제성이 있는지?
0
164
2
클래스 접근자 강의 복습부분 0:47에 오타가 있네요
0
104
2





