작성
·
251
0
def generator_ex1():
print('Start')
yield 'A Point'
print('Continue')
yield ('B Point')
print('End')
temp2 = [x * 3 for x in generator_ex1()]
print(temp2)
Start Continue End ['A PointA PointA Point', 'B PointB PointB Point']
결과 값은 이렇게 나옵니다.
"temp 변수안에 list Comprehension을 통해 [A PointA PointA Point, B PointB PointB Point]가 저장되고, 저장 과정에 있어서 Generator_ex1의 실행으로 Start, Continue, End가 출력됬다"고 이해를 했는데
여기서 temp 변수안에 Start, Continue, End도 출력된 상태로 함께 저장되어 있는 건가요?
그래서 print(temp)를 할 때도 위에 결과가 출력되는 건가요?
항상 좋은 답변과 강의 감사드립니다.
답변 1
0