-
Notifications
You must be signed in to change notification settings - Fork 0
/
auction.py
38 lines (22 loc) · 943 Bytes
/
auction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
bids = {} # create an empty dictionary
continue_bidding = True
def find_highest_bidder(bidding_dictionary):
winner = ""
highest_bid = 0
max(bidding_dictionary)
for bidder in bidding_dictionary:
bid_amount = bidding_dictionary[bidder]
if bid_amount > highest_bid:
highest_bid = bid_amount
winner = bidder
print(f"The winner is {winner} with a bid of ${highest_bid}")
while continue_bidding:
name = input("What is your name?") # Ask the user for input
price = int(input("What is your bid? $")) # Ask the user for input
bids[name] = price # Sava data into dictionary {name: price}
should_continue = input("Are there any other bidders? Type 'yes' or 'no'.\n").lower() # if new bids need to be added
if should_continue=="no":
continue_bidding = False
find_highest_bidder(bids)
elif should_continue =="yes":
print("\n" * 20)