why following code not throw error?
while 7: print ("hi") instead, prints "hi" forever.
because expression 7 considered true in boolean context (like while test).
all non-zero numbers true in boolean context. non-empty strings, , non-empty lists, tuples or dictionaries.
basically, not empty, not none or false , not numerical 0 considered true value. see truth value testing.
Comments
Post a Comment