Created
March 6, 2024 17:40
-
-
Save elyasha/87d7b6b96a144b3239f4c4145706a443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
output = dict() | |
try: | |
friends_count = int(input("Enter the number of friends joining (including you):")) | |
if friends_count < 1: | |
print("No one is joining for the party") | |
else: | |
print("Enter the name of every friend (including you), each on a new line:") | |
for i in range(friends_count): | |
name = input() | |
output[name] = 0 | |
# print(output) | |
total_bill = float(input("Enter the total bill value:\n")) | |
lucky_enabled = input("Do you want to use the \"Who is lucky?\" feature? Write Yes/No:\n") | |
if lucky_enabled == "Yes": | |
random_number = random.randint(0, friends_count) | |
# print(random_number) | |
lucky_friend = list(output.keys())[random_number] | |
# print(lucky_friend) | |
print(f"{lucky_friend} is the lucky one!") | |
for name in output: | |
if name == lucky_friend: | |
output[name] = 0 | |
else: | |
output[name] = round(total_bill / (friends_count - 1), 2) | |
print(output) | |
else: | |
print("No one is going to be lucky") | |
for name in output: | |
output[name] = round(total_bill / friends_count, 2) | |
print(output) | |
except Exception: | |
print("No one is joining for the party") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment