Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

Write me a python code that takes my input (input contains lowercase and uppercase…

  1. User

    Write me a python code that takes my input (input contains lowercase and uppercase letters and numbers 1-9) then prints all the permutations of the inputs together and asks me how many characters do you want. Print the output in a text file and each text file has 1000 lines.

  2. Assistant

    import itertools

    Get user input

    user_input = input("Enter a string containing lowercase and uppercase letters and numbers: ")

    Get all permutations of characters

    permutation_list = list(itertools.permutations(user_input))

    Ask user input for the number of characters they want

    num_chars = int(input("How many characters do you want? "))

    Print output to text file with 1000 lines per file

    num_files = len(permutation_list) // 1000 + 1 for i in range(num_files): with open("output{}.txt".format(i+1), "w") as file: for j in range(i*1000, (i+1)*1000): if j < len(permutation_list): if len(permutation_list[j]) == num_chars: file.write("".join(permutation_list[j]) + "\n")