-2

I don't how to make the script repeat this function if the user doesn't input the correct information.

def installer(x):
if x == "Y" or x == "y":
    print("Ok, Getting On with the install")
    noncustompath()
elif x == "N" or x == "n":
    print("Ok, Cool")
else:
    #Repeat function

Thanks.

LogicalDev
  • 11
  • 3

2 Answers2

0

Use a while loop:

def installer(x):
    if x.upper() == "Y":
        print("Ok, Getting On with the install")
        noncustompath()
        return True
    elif x.upper() == "N":
        print("Ok, Cool")
        return False

installed = False
while not installed:
    user_input = str(input())
    installed = installer(user_input)
JE_Muc
  • 5,403
  • 2
  • 26
  • 41
Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65
0

In programming, there is a mechanism to return something from a function.

In your case, this could be a simple boolean - true or false.

def installer(x):
    if x == "Y" or x == "y":
        print("Ok, Getting On with the install")
        noncustompath()
        return True
    elif x == "N" or x == "n":
        print("Ok, Cool")
        return True
    else:
        return False

   x = input()
   while not installer(x):
       x = input()
Petar Velev
  • 2,305
  • 12
  • 24