Carpark Lab-File Manipulation

I am struggling to open the car park text file for each of the following, see the code below:

Any help would be appreciated! :slight_smile:

The function of this program is to show the user current layout of a car park, provide statistics, and reserve a spot

file_name = open("carpark.txt")
dataset = []

while True:
    print("Select your choice from the menu:")
    print("D to display current status of car park")
    print("R to reserve an empty slot in the car park")
    print("S to display % occupancy of the car park")
    print("Q to Quit program")
    user_input = input("")

# this will display the current car park text file
    if user_input == "D":
        for row in dataset:
            for col in row:
                print(col, end="")
# this will allow the user to reserve a slot
    elif user_input == "R":
        row = int(input("Row:"))
        col = int(input("Col:"))
         if dataset[row][col] == "X":
            print("Sorry slot is already taken")
            elif col > 7:
            print("Parking spot is not available")
            dataset[row][col] = "X"
            print("Parking spot successfully booked!")
        print("Invalid entry")
# this will show the occupancy of the parking lot
    elif var = user_input == "S"
            count = 0
            total = 80
    for row in dataset:
        for col in row:
            if col == "X":
                count += 1
                print("Occupancy %", end="")
                print((count * 100) / total)
            elif user_input == "Q":