wrong answer

whats wrong with my code…

def idol(a):

p={} 
for each in a:
    p[each]=1
if "cakewalk" and "easy" and "simple" and("easy-medium" or "medium") and ("medium-hard" or "hard") in p:
    return("Yes")
else:
    return("No")

t=int(input())

m=[]

l=[]

for i in range(1,t+1):

b=int(input())
for i in range(1,b+1):
    s=input()
    m.append(s)
l.append(m)
m=[]

for each in l:

x=idol(each)
print(x)

Problem Code: C00K0FF

From what it seems, is that you keep on appending list ‘m’ in ‘l’ and then instead for checking for the last appended list in l, you run a loop for all of them, so it prints more than one answer.

What you should do is: place the m=[] inside loop running t times. So now, you’ll have a new list for every test-case. Rest of your code is fine, only change x=idol(each) to x=idol(m). You can remove that l=[] list, as it is not required anymore.

P.S. Please mention the question. And provide a link with properly formatting of code.

please help me again…here is my code…

https://www.codechef.com/viewsolution/15591517

Here the Code : https://ideone.com/kDFmIV , it gives AC

There’s problem with your (if … in p:), results depend entirely on last element (i.e. medium-hard or hard).

Thanks…it worked:)

Please mark the answers which helped you as accepted by clicking on “tick in circle.” Dont use award points for that! :slight_smile: