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:
print(‘i’, end = ” “)

What will be the output of the following Python code?
x = “abcdef”
i = “a”
while i in x:
print(‘i’, end = ” “)
a) no output
b) i i i i i i …
c) a a a a a a …
d) a b c d e f

Answer: b
Explanation: Here i i i i i … printed continuously because as the value of i or x isn’t changing, the condition will always evaluate to True. But also here we use a citation marks on “i”, so, here i treated as a string, not like a variable.

Join The Discussion