Skip to content

(김*혁 시험문제 30번 질문) #143

@kc937

Description

@kc937
data = (" Kim ", " Lee ", " Park ")
result = '-'.join([name.strip().upper() for name in data])
print(result)

파이썬은 위에서 아래로, 왼쪽에서 오른쪽으로 코드를 읽는 것으로 알고 있습니다. 그런데 [name.strip().upper() for name in data] 같은 코드에서는 뒤쪽의 for문에서 name이라는 변수가 정의되는데도 앞쪽에서 사전에 정의되지 않은 name을 먼저 사용해도 에러 없이 실행되는 이유가 궁금합니다.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions