Adblock breaks this site

[PYTHON] Theatre booking system

Discussion in 'Programming General' started by HamzaAbbasi, Apr 3, 2014.

  1. HamzaAbbasi

    HamzaAbbasi Guru

    Joined:
    Dec 21, 2011
    Posts:
    1,126
    Referrals:
    0
    Sythe Gold:
    16
    [PYTHON] Theatre booking system

    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~
     
  2. HamzaAbbasi

    HamzaAbbasi Guru

    Joined:
    Dec 21, 2011
    Posts:
    1,126
    Referrals:
    0
    Sythe Gold:
    16
    [PYTHON] Theatre booking system

    Bump, any help please?
     
  3. HamzaAbbasi

    HamzaAbbasi Guru

    Joined:
    Dec 21, 2011
    Posts:
    1,126
    Referrals:
    0
    Sythe Gold:
    16
    [PYTHON] Theatre booking system

    Bump again, someone must have a clue as to whats wrong?
     
  4. HamzaAbbasi

    HamzaAbbasi Guru

    Joined:
    Dec 21, 2011
    Posts:
    1,126
    Referrals:
    0
    Sythe Gold:
    16
    [PYTHON] Theatre booking system

    Fixed the problem. Thanks anyway.
     
  5. mali123

    mali123 Newcomer

    Joined:
    Sep 18, 2014
    Posts:
    1
    Referrals:
    0
    Sythe Gold:
    0
    [PYTHON] Theatre booking system

    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
     
< RSS Question | SQL help >


 
 
Adblock breaks this site