"""

NAME = 'alex'          # global variable be capital

def change_name():

     global name       # if no declaring the global name can also change the clglobal variable bu using the method of list:such as .appened()

     name = 'handsome' # local variable,be lower-case can have the same name,the difference between "c" program

     print('abcd',name)

     

change_name()

print(name)

 

# ***********Function nest fuction*********

NAME = 'alex'

def zxver():

    name = 'zxver'

    print(name)

    def liu():

        name = 'liu'

        print(name)

        def linda():

            name = 'linda'

            print(name)

        print(name)

        linda()

    liu()

    print(name)

zxver()

 

# ********import easily be wrong

AssertionErrorname = 'alex'

def zxver():

    name = 'zxver'

    def liu():

        #1:global name

        nonlocal name 

        # 2:last stage's variable

        name = 'liu'

    liu()

    print(name)

    # ********1:print:zxver************

    # ********2:print:liu************

print(name)

zxver()

print(name)

# be careful: before the quote ,every function must be defined or will report wrong

 

# ********recursion***************

def calc(n):

    print(n)

    if (int(n/2) == 0):

       return(n)

    res = calc(int(n / 2))

    return(res)

calc(10)

"""

# *********defect:low efficiency*******

import time

person_list = ['alex','keyu','zxver','linda']

def askway(person_list):

    print('-'*60)

    if len(person_list) == 0:

        return 'no one knows the way'

    person = person_list.pop(0)

    if person == 'zxver':

        return '%ssaid the way is turn left'%person

    print('do you know the way of the hall')

    print('%ssaid I do not know the way but i can ask %s'%(person,person_list))

    time.sleep(5)

    res = askway(person_list)

    print('%s the result is :%res'%(person,res))

    return res

    

res = askway(person_list)

print(res)