This is the code
import datetime
mylist = []
today = datetime.date.today()
mylist.append(today)
print(mylist[0])
file = open('Date.txt', 'a')
file.write(mylist)
file.close()
global timestable
global text
def timestable():
global name
name = input("What is your name? ")
global number
number = int(input("Insert a number you want the 12 times table for: "))
global multiply
for multiply in range(1,13):
print(number,"x",multiply,"=",number*multiply)
text()
def text():
file=open("list.csv","a")
file.write("The date is," + today + "\nTimestables are:\n" + number + "x" + multiply + "=" + number*multiply + "\nYour name is, " + name)
file.close()
text()
timestable()
The problem is that nothing is being outputted into the file and its supposed to be outputted with a certain format also.
The error is
Traceback (most recent call last):
File "D:\Python\Code\Lesson Task Code.py", line 9, in <module>
file.write(mylist)
TypeError: must be str, not list