Как прочитать список и сохранить его в текстовом файле внутри одной функции, используя python3?пожалуйста, кто-нибудь, помогите мне
string=["my name is john"," my anniversary is on 04/01/1997","yes","ok"]
def create_file(file_name):
for i in string:
with open(file_name, "w") as input_file:
print(" {}".format(i), file = input_file)
def read_file(file_name):
create_file(file_name)
input_file = open(file_name, 'r')
read_file('file.txt')
with open('file.txt','r') as f:
input_file = f.readlines()
Ожидаемый результат: (в текстовом файле)
my name is john
my anniversary is on 04/01/1997
yes
ok