进程以退出代码 0 结束 - 怎么了?

Process finished with exit code 0 - whats wrong?

我做了这样的东西,不知道为什么不会 运行:

def play_game():

name = (input("Whats your name? "))
age = int(input("How old are you? "))
year = str((2021-age)+100)
print(name+" you will be 100 years old in "+year)
play_again = input("Play again? Yes/No")
if play_again == "Yes":
    play_again = True
else:
    play_again = False
if play_again:
    play_game()

该代码只声明了函数,尝试在函数本身之外添加play_game()

除了此处提出的其他要点外,请记住 Python 需要适当的缩进。所以代码应该缩进如下:

def play_game():
     name = (input("Whats your name? "))
     age = int(input("How old are you? "))
     year = str((2021-age)+100)
     print(name+" you will be 100 years old in "+year)
     play_again = input("Play again? Yes/No")
     if play_again == "Yes":
          play_again = True
     else:
          play_again = False
     return play_again  # you either have to create a global variable or you have to return play_again otherwise this is meaningless

# This both calls the function but also stores the value
# returned from the function
returnedValue = play_game() 
while returnedValue:
    returnedValue = play_game()
def play_game():

    name = (input("Whats your name? "))
    age = int(input("How old are you? "))
    year = str((2021-age)+100)
    print(name+" you will be 100 years old in "+year)
    play_again = input("Play again? Yes/No")

    if play_again == "Yes":
        return True
    else:
        return False


play_game()
if play_game() == True:
    play_game()