Предмет: Информатика,
автор: rahatmarat76
Write a Python program that asks user for name of the file and text that file should contain. Create a text file with given name and fill it with text that entered by user.
Input:
Enter a file name: sample
Enter a text of the file: This file was created at informatics lesson by using
Python programming language.
Ответы
Автор ответа:
1
Code:
name = input("Enter a file name: ") + ".txt"
text = input("Enter a text of the file: ")
with open(name, "w") as file:
file.write(text)
Output:
Enter a file name: abc
Enter a text of the file: 12345
abc.txt file is created with the text: 12345
Интересные вопросы
Предмет: Русский язык,
автор: maksdima
Предмет: Русский язык,
автор: kanginanton
Предмет: Русский язык,
автор: madinayunusova
Предмет: Русский язык,
автор: polinalevina1