Python 질문 while not str
조회수 1507회
name = ''
while not name: #### ➊
print('Enter your name:')
name = input()
print('How many guests will you have?')
numOfGuests = int(input())
if numOfGuests: #### ➋
print('Be sure to have enough room for all your guests.') #### ➌
print('Done')
이 코드에서 while not name
이 while not name != "
이라 들었는데 while not name != "
이게 name
이 거짓이 아닌게 아닐때 까지 라는 뜻 인가요? 너무 헷갈리는데 무슨 뜻인지 설명좀 해주시면 감사하겠습니다
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
1 답변
-
print(not '') # true print(not None) # true
while
은 조건식이true
면 반복합니다.not name
은name == ''
혹은name == None
입니다.따라서
while not name:
은name
의 값이false
로 평가되는 값이면 반복문을 수행하라는 뜻입니다.
댓글 입력