← Quiz: Python Conditions: all 13 questions
Quiz: Python Conditions · Question 12 of 13
Which line correctly checks that a string name is empty?
Which line correctly checks that a string name is empty?
- A.if name == None:
- B.if name.empty():
- C.if not name:
- D.if name = "":
Answer & explanation
Correct answer: if not name:
An empty string is falsy, so not name is True when it is empty. (name = "" is assignment and a SyntaxError here.)
Can you get the rest right without peeking?
Take the timed Quiz: Python Conditions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →