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