用這篇來改成
# -*- coding: UTF-8 -*-
import random
playornot = input('是否要玩猜數字的遊戲?')
if (playornot=='y' or playornot=='yes'):
selnumber = random.randint(1,10)
gotyou = 0
while gotyou==0:
guess = int(input("請猜數字(1~10):"))
if guess == selnumber:
print('答對了,答案是 %d'%(selnumber))
againornot = input('是否要繼續此遊戲?')
if (againornot=='y' or againornot=='yes'):
selnumber = random.randint(1,10)
gotyou = 0
else:
gotyou = 1