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