개발/파이썬

Python 인강 Day 9 / day 100 (비밀 경매 프로젝트)

배타브 2023. 3. 13. 19:10
728x90
반응형
from replit import clear
from art import logo
print(logo)

bids = {}
bidding_finished = False  

def find_highest_bidder(bidding_record):
  highest_bid = 0
  winner = ""
  # bidding_record = {"Angela": 123, "James": 321}
  for bidder in bidding_record:  
    bid_amount = bidding_record[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 not bidding_finished:  
  name = input("What is your name?: ")
  price = int(input("What is your bid?: $"))
  bids[name] = price
  should_continue = input("Are there any other bidders? Type 'yes or 'no'.\n")
  if should_continue == "no":
    bidding_finished = True
    find_highest_bidder(bids)
  elif should_continue == "yes":
    clear()

얼마전부터 느꼈지만 해외강의다 보니 풀수있는 문제도 자막때문에 문제이해가 쉽지 않아 어려움을 겪는다...ㅠ

영어공부부터 해야하나...

728x90
반응형