正在做我的 Python 评估,除了不断地展示自己之外,我无法让我的功能做任何事情。它不会退出或转移到下一个功能对不起,如果这有点傻,但我真的不知道该怎么做或如何描述问题    def main_menu():              menu_choice = input("""---------------------------------------Welcome to the GCSE Celebrity Dogs Game Please choose an option from the menu---------------------------------------1) Play the game2) Quit""")    if menu_choice == 1:     deck_choice()    elif menu_choice == 2:     print("Exiting game.....")     quit()    else:     main_menu()correct_numbers = [6,8,10,12,14,16,18,20,22,24,26,28,30]def deck_choice():    num_cards = input("""How many cards owuld you liek to play with?**Please note this must be a number between 4 and 30 and cannot be odd**""")    if num_cards not in correct_numbers:        print("Sorry, that number isnt valid. Please enter another number")    else:        return num_cardsmain_menu() 
                    
                    
                1 回答
 
                    
                    
                            开心每一天1111
                            
                                
                            
                        
                        
                                                
                    TA贡献1836条经验 获得超13个赞
您需要将 to 转换为menu_choicetoint以便您可以将其与 an 进行比较,int或者将 int 转换为if语句中的字符串。
例如,要将输入转换为 int:
menu_choice = input("""your menu""")
if int(menu_choice) == 1:
# do stuff
或者,将 int 转换为字符串:
menu_choice = input("""your menu""")
if menu_choice == str(1):
# do stuff
添加回答
举报
0/150
	提交
		取消
	