Python Forum

Full Version: Appending to a text string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(May-03-2020, 09:44 AM)syno7878 Wrote: [ -> ]I tried your code and I got the following error message. I'm using Python 2.7:
Stop using Python 2.7 is not supported anymore,will not be maintained at all past 2020.
f-string that i use was new in Python 3.6 -->

For python 2 use .format
f = open("password.txt", "r")
s = f.read()
f_out = open("password2.txt", "wt")

for count in range(1900,2021):
    f_out.write('{}{}\n'.format(s, count))
f_out.close()
Output:
password1900 password1901 password1902 password1903 password1904 password1905 .....
Pages: 1 2