I have a recursive function that calls itself until it gets the correct input.
def input_something(prompt = ""):
playerInput = input(prompt)
if playerInput == "":
print("Error: No input")
input_something(prompt)
elif not playerInput.isspace():
return playerInput
else:
print("Error: Incorrect input")
input_something(prompt)
while True:
print("Input Value")
inp = input_something("> ")
print(type(inp))
print(inp)
print("\n")
The function works fine if you give it a normal value however it breaks if you first give it an empty string and then a character/string. Instead of outputting the string as intended it gives a None type.
Can anyone explain this?