Q. Consider the following code:


string = input("Enter a string :")

count = 3

while True :

    if string[0] == 'a':

        string = string [2 :]

    elif string[-1] == 'b':

        string = string [: 2]

    else:

        count += 1

        break

print(string)

print(count)


What will be the output produced, if the input is:
(a) aabbcc
(b) aaccbb
(c) abcc

Answer :-

(a)
Enter a string :aabbcc
bbcc
4
>>>

(b)
Enter a string :aaccbb
cc
4
>>>

(c)
Enter a string :abcc
cc
4
>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post