asked
Getting Started with Programming: Introduction to Python (Inflearn Original)
while(3-1) : It's a little different from the for syntax
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'를 인덱스 하라는 의미가 아닌가요?
Answer 1
단어 자체를 'qux'와 일단 비교 하는 것 입니다.