Home > Net >  Why isn't all the output showing in the python terminal?
Why isn't all the output showing in the python terminal?

Time:09-21

I'm trying to print all the combinations of AAA-ZZZ but I can't see all the outputs from the terminal. It prints all from A to Z but when it is displayed overall in the terminal, it only shows the combination from y-z and I can't scroll up anymore.

import itertools
for v in itertools.product(['A', 'B', 'C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'],repeat = 3):
  print(v)

CodePudding user response:

It's due to buffer size of your cmd. You need to change buffer size .

Ref: Check this

or else

Solution 2

simply you can save output to list & print them. This will show complete output

import itertools
li= []
for v in itertools.product(['A', 'B', 'C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'],repeat = 3):
  #print(v)
    li.append(v)
    print(*li, sep="\n")

CodePudding user response:

If terminal is giving problem, how about saving the result in txt file then reading the output there. I could see all the results in my python IDLE. I used this code to save file and read it on notepad.

import itertools
file=open("result.txt",'w')
for v in itertools.product(['A', 'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'],repeat = 3):
    file.write(str(v))
file.close()
  • Related