강의

멘토링

커뮤니티

Inflearn Community Q&A

alsgp04078293's profile image
alsgp04078293

asked

Getting Started with Programming: Introduction to Python (Inflearn Original)

while(3-1) : It's a little different from the for syntax

while문 예제7

Written on

·

155

0

a = ['foo', 'bar', 'baz', 'qux']

s = 'qux'

i = 0

while i < len(a):

    if a[i] == s:

        break

    i += 1

else:

    print(s, 'not found in list')

 여기에서, a[i] 부분이 이해가 가지 않습니다.

i = 0 인데 a[i]로 인덱스를 하면,  리스트 a의 0번째 문자열인 'foo'를 인덱스 하라는 의미가 아닌가요?

python

Answer 1

0

niceman님의 프로필 이미지
niceman
Instructor

단어 자체를 'qux'와 일단 비교 하는 것 입니다.

alsgp04078293's profile image
alsgp04078293

asked

Ask a question