Q. Predict the output of following code if the input is:
(i) 12, 3, 4, 5, 7, 12, 8, 23, 12
(ii) 8, 9, 2, 3, 7, 8
Code:
s = eval (input("Enter a list : "))
n = len(s)
t = s[1:n-1]
print(s[0]==s[n-1] and t.count(s[0])==0)
Answer =
(i)
Output:-
Enter a list : [12, 3, 4, 5, 7, 12, 8, 23, 12]
False
>>>
(ii)
Output:-
Enter a list : [8, 9, 2, 3, 7, 8]
True
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )