所以我有這個程序,它的工作原理(數學),即使用戶可以使用它沒有問題。唯一的問題是,最終當程序要求用戶退出或重新啓動時,不要這麼做! 那麼我該如何重新開始遊戲! 謝謝大家的幫助如何重新啓動大循環(其中2個其他小循環)
print('guess what number im thinking of\n')
Max=int(input('Give us your hights number that your interval can have:'))
Min=0
print'Now think to a number between 0 and',Max,'once you have chose your numebr'
print'Great !'
print'its your turn to help us,if the number is :Exacte (0),higher(1)or lower(-1)'
milieu=(Max-Min)/2
print int(milieu),'is that the number your thinking of ?'
z=input(str('its important that you only answer by 0, 1 or -1:'))
x=False
while milieu<Max and x==False:
if z==0:
print('We had guess what number you chosed')
x=True
while z!=0:
if z==1:
x=False
Min=milieu
milieu=milieu+((Max-Min)/2)
print(int(milieu))
z=input('its important that you only answer by E, G or P:')
if z==-1:
x=False
Max=milieu
milieu=(milieu-((Max-Min)/2))
print(int(milieu))
z=input('its important that you only answer by E, G or P:')
break
while x==True:
a=input('[5] to go out game\nor [9] to restart:')
if a==5: break
print ("restart")
if a==9:
x=False
其實我想,如果用戶按9,它會重新啓動遊戲(開始) – 2014-09-29 00:15:11
你的超級真棒! It worked :) 謝謝 – 2014-09-29 00:25:59