我的代码中的此功能(菜单)有问题,返回的是None,但是当我打印input(option)的值时,它会正常打印。请遵循整个代码:
class Menu(object):
def __init__(self):
pass
def menu(self):
print("\n|1|")
print('Play Game\n')
print("-=" * 30)
print("\n|2|")
print('Quit\n')
option = int(input('Digit 1 to play the game \n\t\tor \nDigit 2 to quit the game'))
print(option)
return option
import menu
menu = menu.Menu()
class Game(object):
def __init__(self):
pass
def numberofcards(self, value=0):
if value > 4 and value < 30 and value % 2 == 0:
return value
else:
print("""Please enter a valid number of cards to continue.The
number should be
greater than four, less than thirty and should be an even number""")
menu.menu()
import game
import menu
menu = menu.Menu()
game = game.Game()
a = game.numberofcards(27)
print(a)