반응형
반응형

문제

vscode 환경에서 파이썬을 가지고 map에 있는 값을 읽을려고 print() 실행 했을 때 <map object at 0x10446d880>이라고 나왔다.

읽을 수 있게 바꿔야 합니다.

 

코드

def twoSum(nums, target):
	# arr map
    arr = map(lambda x: x < target, nums)

nums = [2,7,11,15]
target = 9
twoSum(nums, target)

 

해결

1. for문

for num in arr:
	print(num)

 

2. map을 list로 담기

arr = list(map(lambda x: x < target, nums))
print(arr)

 

 

반응형

'Python' 카테고리의 다른 글

File 읽어서 객체에 담기  (0) 2024.09.04
파이썬 lambda 사용시  (0) 2023.06.01
[python] list 사용 방법  (0) 2023.05.29
zip()  (0) 2023.05.03
combinations()  (0) 2023.05.03

+ Recent posts