Ad
  • Custom User Avatar

    oh yes my bad

    permutations refers to the name of the function i.e., the user is using a recursive function as his solution

  • Custom User Avatar

    yes, but as i recall you should import itertools module first before use the permutations method, and clearly there is no import command in the code above. does this "permutations" refered to the name of the function?

  • Custom User Avatar

    e.g.,

    permutations = 'abcde'
    print(permutations[:2]+permutations[2+1:])
    
    

    will return

    abde
    
  • Custom User Avatar

    what does "permutations(s[:i]+s[i+1:])" do?

  • Default User Avatar

    Here are 2 similar examples you can copy into your IDE and see if it makes sense:

    list_of_nums = [3,4,5,6,7,98,99]
    
    true_or_false_1 = any(x>4 for x in list_of_nums)
    true_or_false_2 = any(x>100 for x in list_of_nums)
    
    print(true_or_false_1) # should print True, there is AT LEAST ONE x in list_of_nums that is > 4
    print(true_or_false_2) # should print False, there are NOT any x's in list_of_nums that are > 100
    
  • Custom User Avatar

    what is the purpose of "any" in the code above?