各位大佬好,我想要写一个计数器,每次一个循环后,计数器数量加一,但不知道怎么实现。麻烦各位赐教defcount_turn(turn=0):ifturn==0:turn+=1elifturn>=1:turn+=1returnturndefadd_turn(turn):turn+=1returnturndefleave_stay():print("="*50)reply=input("Doyouwanttoquitthegameorcontinueplaying?""\n'q'forquit,'c'forcontinue")print("")returnreplydefexecute(reply,):ifreply=='q':signal=Falsereturnsignalelifreply=='c':main()else:leave_stay()defmain(turn=0):turn=count_turn(turn)print("first:",turn)signal=Trueifsignal:turn=count_turn(turn)turn=add_turn(turn)print("hereistheturn:",turn)reply=leave_stay()execute(reply)main()
梦里花落0921
猛跑小猪
相关分类