[Python] ZyBooks name permutation python

Discussão em 'Python' iniciado por Stack, Janeiro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I have a problem when learning the zyBooks about Python. 7.4 LAB asks me to write a program about all permutations of names. The details are shown below.

    [​IMG]

    Here is my code but I do not know why there is no output. Could you please help me with it? Really appreciate it.

    def all_permutations(permList, nameList):
    # TODO: Implement method to create and output all permutations of the list of names.
    import itertools
    permList = list(itertools.permutations(nameList))
    return permList

    if __name__ == "__main__":
    nameList = input().split(' ')
    permList = []
    all_permutations(permList, nameList)

    Continue reading...

Compartilhe esta Página