pat05453
24.03.2021 23:26

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.

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
inlivemulorada
03.04.2021 05:57
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

0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота