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


x = (i for i in range(3))
for i in x:
    print(i)

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