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