Предмет: Информатика,
автор: 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
Похожие вопросы
Предмет: Русский язык,
автор: ekermar
Предмет: Русский язык,
автор: палтарашка
Предмет: Русский язык,
автор: 14d2005
Предмет: Математика,
автор: Killdit
Предмет: Физика,
автор: XOLOD222