15,992,587 members
See more:
Python
```highest_bid = 0
winner = None
for bidder in bid_log:
bid_amount = bidder["bid"]

if bid_amount > highest_bid:
highest_bid = bid_amount
winner = bidder
print(f"The winner is {winner['name']}")
```

What I have tried:

I tried looking up how it's done, but it was very complicated. So, I hope someone here can help.
Posted
Updated 27-Oct-23 5:24am
v3
Hamza Ayub 26-Oct-23 7:48am
the code looks like this because of the editor in this website
. so dont mind that

Solution 1

An heavily commented copy of the above code:
Python
```highest_bid = 0 ##  assuming bids are greater than 0, this is a good initialization value
winner = None   ## another sensible initialization value
for bidder in bid_log: ## this is a loop over the items of the list, every item is a dictionary, e.g. { "Name" : "Bob", "bid" : 100 }

bid_amount = bidder["bid"]  ## retrieve the bid from the current dictionary

if bid_amount > highest_bid: ## if the bid is greater than the (current) maximum then...
highest_bid = bid_amount  ## update the current maximum bid value
winner = bidder ## keep track of the relative bidder

print(f"The winner is {winner['name']}") ## eventually output the result```

v2
Hamza Ayub 26-Oct-23 8:05am
thanks, that simplifies it in a very simple manner.

Thank you
CPallini 26-Oct-23 8:31am
You are welcome.
Maciej Los 27-Oct-23 11:28am
5ed!
CPallini 27-Oct-23 12:38pm
Thank you!
Maxim Kartavenkov 27-Oct-23 13:48pm
5.