Answer to Question #125167 in Python for bhavisha

Question #125167
If the customer has his/her personal bag which is not allowed
in the supermarket, his/her personal bag is kept at the
entrance of the supermarket and the system allocates him/her
an empty compartment number. This is the compartment
where the customer’s personal bag will be kept then he/she
proceeds to do his/her shopping.
1
Expert's answer
2020-07-07T09:55:10-0400
def system(has_bag=True):
    global compartment
    if not has_bag:
        return True, None
    for cell in compartment:
        if cell.empty:
            cell.empty = False
            return True, cell.key
    return False, None

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS