I am trying to print out the highest bidder Part 2 *Beginner*
You can move maxBid
out of the for
loop, in your keep_gooing == 'no'
case. It would look like this:
maxBid = 0
maxBidName = ""
for bidder in bidders:
bid = int(bidder["bid"])
name = bidder["name"]
if bid > maxBid:
maxBid = bid
maxBidName = name
print(f"Congratulations {maxBidName}! Your bid of ${maxBid} wins!")
If the maxBid
is inside the for loop, it will be setted to -1
every time the loop runs!