Level 9 : What will be the output of the following Python code?


for i in range(10):
    if i == 5:
        break
    else:
        print(i)
else:
    print("Here")

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