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


x = ['ab', 'cd']
for i in x:
    x.append(i.upper())
print(x)

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