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


x = 'abcd'
for i in range(len(x)) :
    print(i)

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