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