I want to print out 3 of the same words on the same line after reading it from a file. So say the word is Test. I want it to print TestTestTest
. Here is the code I came up with, but it prints each as a separate line. How do I fix this?
import os
file = open('rockyou.txt', 'r')
for line in file:
output = line.title()
print(output+output+output)
It must have newlines:
for line in file:
output = line.strip().title()
print(output + output + output)
Instead of output + output + output
, just do multiplication:
for line in file:
output = line.strip().title()
print(output * 3)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.