0

I'm fairly new to python and programming in general, and so hope the community can help me out where I can't find helpful solutions on google.

I have searched for what "print >>" does on google, on this site, and by using ctrl+f on many tutorials on printing for python and have not found a single one explaining what "print >>" does. So what do the ">>" add to the print function?

I have shown some of my course's notes below to show the usage of this, and while I can guess what print >> i want to be sure and a helpful explanation would be great. Thanks!

Example:

infile = open(sys.argv[1], 'r') # open input file
outfile = open(sys.argv[2], 'w') # open output file 

num = 0
label = "*"
for line in infile: # read input file stream, line by line 
    num = num+1
    print >> outfile, label, num, line #write to out-stream

infile.close() 
outfile.close() 
Darkphoton
  • 506
  • 4
  • 14

0 Answers0