Hello! I am new to python and learning about functions and how to return a value. I have an assigment that says to “create a function who returns the third character in a string, if the string is shorter than three characters it should return false”.
I am able to make the function return the third sign in a string, but I can´t get it to return False when the string is shorther than characters.
Anyone who can help me figure out why it wont return false? This is the code I´ve written:
def third_character(string): x = string print(x) if len(string) > 2: return x else: return False third_character() #In there you enter a string with "" around
Thankful for help