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