How to add new list to existing list in a text file in Python

1 Answer

0 votes
a_new_list = ["php", "html", "css", "javascript"]

with open("d:\\data.txt", "a") as file:
    for item in a_new_list:
        file.write("%s\n" % item)


'''
run:

python
java
c#
c
c++
php
html
css
javascript

'''

 



answered Oct 21, 2017 by avibootz

Related questions

1 answer 144 views
144 views asked Aug 11, 2023 by avibootz
1 answer 212 views
1 answer 107 views
...