• Log in or sign up for an account here: https://www.sythe.org/login

[PYTHON] Theatre booking system

Joined
Dec 21, 2011
Sythe Gold
18
Messages
1,130
Location
London
EDIT: I've just realized this could be classified as a request for completion however, I'd like to make it clear that its not! I just require help, if it is classed so please do delete and let me know, thanks and sorry!

Hi, I've been tasked with creating a code that checks through a multidimensional array of several true or false values to see whether a seat is free or not.
Please do not bother flaming me or whatever I know I'm not too good at python, I have a way to go but that's why I came for help here.
Code:
def seatCheck(seats):
    bL = 0 # Biggest Length
    cL = 0 # Current Length
    bS = 0 # Biggest Starting-point
    cS = 0 # Current Starting-point
    
    for x in range(len(seats)):
        if not seats[x]:
            cL += 1
            if cL > bL:
                bL = cL
                bS = cS
        else:
            cL = 0
            cS = x + 1
    if bL > uI:
        print("There are", bL, "seats available starting from", row,bS)
    elif uI > bL:
        print ("There are no seats available")
    else:
        print ("There are no seats available")
offByOne=[[0,1,0,0,0,1,0,0,1,0],
         [1,0,0,0,0,0,0,0,0,0],
         [0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,1,1,1,1],
         [1,0,0,1,1,1,1,1,1,1]]
uI = int(input("how many seats do you want? "))
if uI > 6:
    print ("maximum of 6 seats")
else:
    listR = ["E", "D", "C", "B", "A"]
    row = input(str("What row do you want?")).upper()
    print (seatCheck(offByOne[listR.index(row)]))

That's the code I've come up with, the problem I'm coming up with at the moment is that of the fact when I ask for any number of seats or a row it'll send back the correct reply, however it also sends back the word "none" I'm not sure why and would like some help on this and/or polishing up my code.

I'm not too sure on how this area works as I haven't been on sythe in a while and am just looking for help, If I've done anything wrong please feel free to let me know, thanks!

Thanks again,

Hamza~
 
Hello,

sorry this is late and you may have solved the problem by now but if you have not...

the problem lies within the last line of the code: print('seatCheck(offByOne[listR.index(row)]))

all you need to do is delete the 'print' function and it will still give the correct answer and remove the word 'None':

so the last part of the code should look like this:

else:
listR = ["E", "D", "C", "B", "A"]
row = input(str("What row do you want?")).upper()
(seatCheck(offByOne[listR.index(row)]))

hope this helps
 
Runescape Gamblingrunescape gambling
Back
Top