Level 9 : What is the output of the below code?


i = 0
while i < 3:
    print(i)
    i += 1
else:
    print(0)

Author: HareramG | Tags: loop | 1859+ Python FAQs | Share
conversion | conditional-statements | built-in | directory-operations | postfix | enumerate() | class-and-inheritance | counter | destructor | generators | else-statement | class-and-instance-variable | data-structures-in-python | lambda-functions | data-type-conversions | fabs-function | function-argument | context-manager | global | data-type | boolean-masking | file_handling | conditional-statement | comparison | file-handling | formatting-with-strftime | exception | default-arguments | matrix | list,-set,-and-dictionary-comprehensions | docstring | data-types | zip-function | set | escape-operator | stack | syntaxerror | conditional-statement | string-slicing | shallow-copy | regular-expression | sorting-and-ranking | tuple-unpacking | working-with-dates-and-times | formal-and-actual-parameter | zip | exception-handling | regex | filter-function | expand-tab | string | sorted | creating-and-starting-threads | file-handling | compute | tuple-methods | class | complex-number | using-os-and-pathlib-modules | design-principle | dictionary | while-and-for-loop | decorator | working-with-temporary-files-using-tempfile | built-in-function | basic | generator | thread-synchronization | using-join()-and-is_alive()-methods | __future__ | data-structures | dictionary-comprehensions | syntax | global-variable | floating-point-precision | software-design | deep-copy | string-method | while-loops | format | comprehension | functions | for | file | built-in-function | error-handling | data-structure | __all__-attribute | frozenset | working-with-file-paths | global-keyword | tuple | function | command-line-parsing | assignment-operator | choice | regular-expressions | with-statement | staticmethod | thread | type-conversion-and-casting | string-method | defining-functions | string-iteration | using-else-and-finally | using-assertions-(assertequal,-assertraises) | string-methods | gil | sys-module | zfill-function | data-type | datetime.date,-datetime.time,-datetime.datetime | threading | expression | error | filter | exception-handling | time-series-with-pandas | assert | class-and-object | while-else-loop | string-formatting | collection | functional-programming | dictionary-methods | generators-in-python | factorial-function | thread-safe-data-structures-(queue.queue) | complex | feature | strings | implementation | version-check | static-method | min-function | exponentiation | loop | heap-memory | arithmetic-expression | namespace | variable | floats | bitwise-operator | function-and-scope | max-min | swapping | split | operations | else | filtering-and-indexing | scientific-notation | membership-operators-(in,-not-in) | string-manipulation | managing-directories-with-os-and-shutil | recurssion | loop-control | methods | oops | statement | writing:-write(),-writelines() | dictionaries | nested-loop | call | goto-function | python-module | interpreter | type-conversion | set-operation | parameter | tuples | mathematical-function | iterable | mysql | reading-and-writing-files | multithreading | loops | string-formatting | lambda-function | list-operation | identity-operators-(is,-is-not) | id-function | why-use-multiprocessing-over-threading?-(gil) | turtle | descriptors | data-structure | lambdas | encoding | init | control-flow | library | input | list-comprehension | async | def | boolean-and-non-boolean | creating-custom-modules | logical-operator | python-django | head-and-tail | sys | overriding-methods | append | constructor | data_structure | round-function | walking-through-directories-using-os.walk() | datatype | map-function | encapsulation | copy | identity-operator | global-variable | counter-function | condition | type-conversion | python-history | recursion | precedence | control-flow | print-statement | bitwise-operator | error-handling | debugging | introduction-to-multiprocessing | list-vs-tuple | class-decorators | operators | print | decimal | operator-overloading | default-mutable-argument | functional-programming | rollback | benefit | higher-order-function | dicts | using-the-threading-module | booleans | list-comprehension | slice | yield | list | pseudocode | handling-missing-values-(fillna,-dropna) | memory-management | syntax-error | test-discovery | syntax-error | input-function | string-slicing | lambda | touples | opening-files-(open()) | while-loop | control-statement | pandas | using-yield-in-functions | classes | collections | mapping-function | overflow | raise | aggregating-data-with-functools.reduce() | boolean | list-join | pep | logical-operation | dataframe-and-series-objects | oop | multiple-inheritance | arithmetic-operation | sum() | inheritance | immutability | list-indexing | identifier | keyword | operator | slicing | int | integer | pass | indentation | typeerror | using-lists-as-stacks | odd-number | virtual-environment | mutable | iterators | __init_subclass__ | datetime | magic-method | difference-between-threads-and-processes | anchors-(^,-$) | binary-operation | return-statement | access-modifier | update | random-function | reading:-read(),-readline(),-readlines() | operator-and | array | memory | assignment-operators | arbitrary-arguments-(*args,-**kwargs) | application | built-in-modules | python_version | asyncio | python-syntax-and-structure | package-management | round | virtual-environment | string-concatenation | asyncio-module | center | precedence-and-associativity | comment | indexing | single-inheritance | list-methods-and-slicing | sets | key-value-pairs | bitwise | sorting | invalid-list | introduction-to-threads | sum-function | join | using-map()-for-transformations | namedtuple | range | unit-testing | module | integers | input-function | installation | introduction-to-python | name-mangling | import-method | multiple-inheritance | multiple-except-blocks | multiprocessing | indexing:-loc-vs-iloc | numeric | loop-control-statements | attribute | intering | iterator | binary | raise-statement | numpy | random | matrix-list-comprehension | pickling--unpickling | immutable-data-type | list-comprehensions | joining-and-merging-dataframes | inherit | identity-operator | object-attribute | objects | logical-operator | advanced-file-operations | python-repl | matplotlib | lists | list-slicing | min-max-function | python | mathematics | quantifiers-(*,-+,-?,-{}) | parsing-with-strptime | operand | operator-or | list-mutation | polymorphism | list-method | reading-and-writing-large-files-efficiently | math | math-copysign | python-operators | match | literal-characters-and-special-characters | method | method-overloading | working-with-binary-files-(rb,-wb) | logical-operators | type_conversion | version ...