I'm making a movie theatre booking system as part of a school project so my knowledge about python is fairly limited.
I have the following code to import the csv file, which stores the status of the seats (0 = not booked and 1 = booked)
import csv
with open('seats.csv', newline='') as csvfile:
seats = list(csv.reader(csvfile))
Here's my code for booking the seat:
def bookSeat():
print("Booking a Seat by Row/Column")
booked = False
while booked == False:
row = int(input("Enter a row number (between 0 and 5)"))
column = int(input("Enter a column number (between 0 and 7)"))
if seats[row][column]==1:
print("This seat is already booked.")
else:
print("This seat is empty.")
print("Booking seat...")
seats[row][column]=1
print("We have now booked this seat for you.")
booked=True
So my question is after booking a seat (replacing the 0 with a 1), how do I update the csv file to reflect this change?
Thanks for all your help in advance!!
csv.writer?open()function