Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adarsh #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions pythonhw.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,51 @@
memberStatus = {
"Ally": True,
"David": True,
"Brendan": False
"Brendan": False,
}

request = {
"applicants": ["Amy", "Ally", "David", "Brendan", "Zoho"]
}


def is_banned(x, bannedVisitors):
if x in bannedVisitors:
return True
else:
return False

def total_cost(y):
total = 0
for i in y:
if memberStatus[i] == True:
total += 3.50
else:
total += 5.00
return total

def processRequest(request):
# Your code here
return
result ={}
result["successfulApplicants"] = list(filter(lambda x: is_banned(x, bannedVisitors)==False, request["applicants"]))
result["bannedApplicants"] = list(filter(lambda x: is_banned(x, bannedVisitors)==True, request["applicants"]))
result["totalCost"] = total_cost(request["applicants"])
result["tickets"] = []
for i in request["applicants"]:
x = input(f"Is {i} a member?")
print(x)
if x.lower() == "yes":
memberStatus[i] = True
if x.lower() == "no":
memberStatus[i] = False

result["tickets"].append({
"name": i,
"membershipStatus": memberStatus[i],
"price": total_cost([i])
})
if request["applicants"] == []:
raise Exception({"error": "No applicants"})
return result


print(processRequest(request))
Expand All @@ -48,4 +82,4 @@ def processRequest(request):

# OR

# {"error": "No applicants"}
# {"error": "No applicants"}