代码之家  ›  专栏  ›  技术社区  ›  Priya

控件在第二次迭代中跳过函数。为什么?

  •  1
  • Priya  · 技术社区  · 6 年前

    我的代码:

    def player_input():
        global symbol1
        global symbol2
        """
        do something
        """
        marker=True      
    
    def replay():
        game=True
        while(game==True):
    
            print('do you want to play?')
            option=input(' enter yes/no ')              
            if option=='no':
                game=False
                break
            while not(option=='YES'): 
                option=input('choose the right option')
    
            marker=player_input()
    
        print('see you around!...bye')
    
    
    symbol1=''
    symbol2=''
    replay()
    

    do you want to play?
    
     enter yes/no   yes
    
    player1 :  x
    
    player2 :  o
    
    do you want to play?
    
     enter yes or no       yes
    
    do you want to play?
    
     enter yes or no        
    

    控件没有进入函数:player\u input for second iteration。

    0 回复  |  直到 6 年前