回到我的脚本的一部分?

时间:2012-03-08 17:07:16

标签: python function input return

我可以制作这样的功能:

def again ():
   again = input ( "want to input the word again ?  yes =1 no =2 ")
   if again == 1:
        func_input_word()
   else:
        return keuzemaken

2 个答案:

答案 0 :(得分:3)

我猜这段代码会做你想要的:

def func_input_word():
    input_word = ""
    while len(input_word) < 6:
        input_word = input("Input a 6 letter word: ")
        if len(input_word) < 6:
            print("Too small, try again!")
        else:
            return input_word
def option(my_choose):  #function named: make choose ( choice )
    if my_choose == 1:
        input_word = func_input_word()
    else:
        ....

答案 1 :(得分:1)

这个怎么样:

def option(my_choose):  #function named: make choose ( choice )
   if my_choose == 1:
       while len(input_word) < 6:
          input_word = input( "type het gekozen 6 letterig woord in : ") #input for word
          if len(input_word) < 6:
             print ("to short, try again ")
          else:
             break
    else:
    ....