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) i i i i i i
b) a a a a a a
c) a a a a a
d) none of the mentioned

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

Join The Discussion