Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Python code?
x = “abcdef”
i = “a”
while i in x:
x = x[1:]
print(i, end = ” “)

What will be the output of the following Python code?
x = “abcdef”
i = “a”
while i in x:
x = x[1:]
print(i, end = ” “)
a) a a a a a a
b) a
c) no output
d) error

Answer: b
Explanation: The string x is being shortened by one character in each iteration.

Join The Discussion