🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.if name == None:
  2. B.if name.empty():
  3. C.if not name:
  4. 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 →