117k views
5 votes
Write a Python program that firstly creates a file named "stars.txt" in the same directory (folder). Then, write 100 star symbols (") into this file using a loop, with one star " in each line.

User Kolesar
by
8.6k points

1 Answer

3 votes

Final answer:

To create a file named 'stars.txt' and write 100 star symbols into it using a Python program, you can use the 'open()' function and the 'write()' method.

Step-by-step explanation:

To write a Python program that creates a file named 'stars.txt' and writes 100 star symbols into it, you can use the 'open()' function to create the file and the 'write()' method to write the symbols. Here's how you can do it:

file = open('stars.txt', 'w')
for i in range(100):
file.write('"\\')
file.close()

User James King
by
7.5k points