0

Альтернативные решения

Как Решить данную задачу без использования метода join names = ["John\n", "Oscar\n", "Jacob\n"] file = open("names.txt", "w+") #write down the names into the file b=''.join(names) file.write(b) file.close() file= open("names.txt", "r") #output the content of file in console print(file.read()) file.close()

5th Oct 2020, 2:56 PM
Павел
Павел - avatar
2 Antworten
+ 2
b = f"{names[0]}{names[1]}{names[2]}"
5th Oct 2020, 3:04 PM
Ipang
+ 1
names = ["John", "Oscar", "Jacob"] file = open("names.txt", "w+") #write down the names into the file for x in names: print(x) file.close() file= open("names.txt", "r") #output the content of file in consol cont = file.read() print(cont) file.close() It took me a little bit less than forever to do it.
29th Mar 2021, 11:40 AM
Bohdan Kudovbenko
Bohdan Kudovbenko - avatar