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


x = 'abcd'
for i in x:
    print(i)
    x.upper()

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