#๐Ÿ”’ Ive made a birthday party program

24 messages ยท Page 1 of 1 (latest)

stuck haven
#
# lets make a program that has people invited to our birthday
# party!

# But UH OH!, our birthday part table only has enough room for
# 6 people, 

Our_table = ["george","samantha",
             "kris","webster",
             "harold","john",
             "miles","hamilton","dog"]

def uninvited_statement(name):
    print(f"Dear {name},\n\tIt has been an unfortunate decision to inform you; {name}, you have been uninvited from our birthday party to be hosted on 1/13/25. We have made the mistake of adding more than 6 people to our birthday party. Here's a $5 Amazon gift card as an apology.\n")


while len(Our_table) > 7-1:
    uninvited = Our_table.pop()
    uninvited_statement(uninvited)
white marlinBOT
#

@stuck haven

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

stuck haven
#

I just wanna know how I can inprove it

#

Like what changes would you recommend?

bright sparrow
#

Not the dog PepeHands

drifting flame
stuck haven
#

ok

spare lily
#

Mb, instead of printing that thing just return it

stuck haven
#

New and updated code:

# lets make a program that has people invited to our birthday
# party!

# But UH OH!, our birthday part table only has enough room for
# 6 people, 

Our_table = ["george","samantha",
             "kris","webster",
             "harold","john",
             "miles","hamilton",
             "dog","Charles"]
def still_invited(name):
    return(f"Dear {name},\n\tWe have made some changes to whom is still remaining in our party. We have made unfortunatly removed some people from our party, However, you; {name} are still invited to our birthday party in which will be hosted on 1/13/25.\n")

def uninvited_statement(name):
    return(f"Dear {name},\n\tIt has been an unfortunate decision to inform you; {name}, you have been uninvited from our birthday party to be hosted on 1/13/25. We have made the mistake of adding more than 6 people to our birthday party. Here's a $5 Amazon gift card as an apology.\n")

while len(Our_table) > 6:
    uninvited = Our_table.pop()
    print(uninvited_statement(uninvited))
for person in Our_table:
    print(still_invited(person))
drifting flame
#

if you want to play around more with this. you could try implementing a priority for each invited person and remove the person with the least priority. this can be done with a heap. implementing a own class for a heap could also be a nice task but there is already an implementation for heaps in the module heapq

#

@stuck haven

bright sparrow
stuck haven
#

print(uninvited_statement(uninvited))?

#

I believe that will create an unexpected indentation error

bright sparrow
#

Oh wait

#

Mobile formatting

stuck haven
#

Why does mobile do that?

bright sparrow
stuck haven
#

Heres what It should look like

white marlinBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.