i am new to Python and am having trouble with this problem. Thanks in advance.
Generate a list of strings of size 10 where each element is a string made up of * characters and length runs from 1 to 10 Write these strings to a text file. Be sure to terminate each string with end of line character, i.e. '\n' Use context manager syntax for writing, i.e. "with" keyword Hint: open file in 'wt' mode for writing.
Instead of using writelines() or write(), use print() function. Hint: print() function has an argument file.
Open the same file for reading and read back all the lines in the file you have just created Do not use context manager when reading the file back. '''
This is what i have so far:
strings = ['*', '**', '***', '****', '*****', '******', '*******', '********', '*********', '**********']
f = open("file.out", 'w')
data = '\n'.join(strings) # Concat all strings in list, separated by line break
f.write(data)
f.close()