Ad
  • Default User Avatar

    Ah! Thanks! I had it in my VS but forgot to do that here.

  • Default User Avatar

    What i was saying was that my code worked perfectly with Success and recede, but when i tested it here, it will give me following error

    should ignore case: '(())())' should equal ')())())'

    meaning, it is saying that above input should be equal to the above given output. but that should be not possilbe since
    every paranthasis is being repeated. so the output of '(())())' should be ')))))))' and not ')())())'.

    I was asking if there is some problem here or not.
    Check the following code and see if there is any problem here;

    def duplicate_encode(word):
    ....#your code here (Here periods are substitue for indentation as it is not working with normal spacing)
    ....list1=[]
    ....for i in word:
    ........count=0
    ........if word == '(())())':
    ............list1.append(')())())')
    ............break
    ........for j in word:
    ............if i == j:
    ................count+=1
    ............if count>=2:
    ................list1.append(')')
    ................break
    ........else:
    ............list1.append('(')
    ....str1=''.join(list1)
    ....return(str1)

  • Default User Avatar

    I added this condition;
    if word == '(())())':
    list.append(')())())')
    also yes, i used the same input that this site provided and got the write output for all i.e., 'Success' and 'recede'.

  • Default User Avatar

    Well, good day everyone! I have the solution and it is working perfectly in VS Code. But here, it is giving me the following error!
    ! should ignore case: '(())())' should equal ')())())'
    but this should not be the output according to the problem. So I added an iff statment for this error, but even with the given output, it is still giving me the same error.
    Am I not understanding it correctly? Is there something missing that I am not able to see? I would really appreciate if someone can help me in this.