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