Computer Science

Predict the output of the following code fragments:

for x in 'lamp':
    print(str.upper(x))

Python

Python Funda

6 Likes

Answer

L
A
M
P

Working

The for loop extracts each letter of the string 'lamp' one by one and place it in variable x. Inside the loop, x is converted to uppercase and printed.

Answered By

3 Likes


Related Questions