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')
I heard that while not name
is while not name!="
in this code, but while not name!="
Does this mean that name
is not false? I'm so confused. Please explain what it means
print(not '') # true
print(not None) # true
Repeat while
if the conditional expression is true
. not name
is name == ''
or name == None
.
Therefore, while not name:
means that if the value of name
is evaluated as false
, repeat the statement.
© 2024 OneMinuteCode. All rights reserved.