Print variables in Python 3.x

Hi Team,

I have two lines that in Python 2.7 print in the same line the output, but in python 3.x is different. I need in the same line:

Part of the script:

for file in dict:
start = time.time()
print “file”, file, " | ",

print lines, “lines,”, messages, “messages,”, matches_found, “matches found,”, “time elapsed”, time_elapsed #prints lines, messages and time it took for that file to completly read

output
file /cxpslogs/powerBI/pruebasTransaction/transaction.log.2024-05-06_10.cexpgtap4p.log | 19296113 lines, 0 matches found, time elapsed 20.9208459854

But in python 3.8 is not the same

file /cxpslogs/powerBI/pruebasTransaction/transaction.log.2024-05-06_10.cexpgtap4p.log |
19296113 lines, 0 matches found, time elapsed

Note: i need in the same line the info. What Do I need to change or modify in the function?

Regards



In order to preserve formatting, please select any code or traceback that you post and then click the </> button.

The equivalent in Python 3 is to use the end keyword argument. This argument tells it what to print at the end and by default is "\n", but it :

print("file", file, " | ", end="")

Hi Matthew
Thanks a lot. Issue fixed!!!