'''python
給定年齡,用戶能夠猜三次年齡git
年齡猜對,讓用戶選擇兩次獎勵code
age_count = 0 age = 20 prize_dict = { '0': "VR眼鏡", '1': "Macpro", '2': "psp遊戲機", '3': "戰術目鏡", '4': "ipone11pro", '5': "chongqiwawa" } prize_msg = ''' 0 VR眼鏡 1 Macpro 2 psp遊戲機 3 戰術目鏡 4 ipone11pro 5 chongqiwawa ''' get_prize_dict = {} while age_count < 3: age_inp = input('請輸入你的年齡:') if not age_inp.isdigit(): print(f'傻吊,你活了aaa歲嗎?') continue age_inp_int = int(age_inp) if age_inp_int > age: print('猜大了') elif age_inp_int < age: print('猜小了') else: print('猜對了') prize_count = 0 while prize_count < 2: print(f'獎品以下:', prize_msg) prize_choice = input('請選擇你須要的獎品:') prize = prize_dict[prize_choice] if prize in get_prize_dict: get_prize_dict[prize] += 1 else: get_prize_dict[prize] = 1 print(f'恭喜你得到獎品 {prize}') prize_count += 1 print(f'總共得到獎品爲:{get_prize_dict}') break age_count += 1