In your code, you are calling string_upper(up) but up is not defined anywhere and that is why you got the error. Same problem is for string_lower().
Another problem is you are returning from string_upper() and string_lower() but not using the return values anywhere. Apart from that you have a print statement in those two functions after the return statement. So, those print statements will never be executed and nothing will be printed in the output.
If you just want the upper case and lower case of input to be printed, you can modify the functions like below -
def string_upper(s):
print("Uppercase Output: ", s.upper()) # Only printing the values and not returning
def string_lower(s):
print("Lowercase Output: ", s.lower()) # Same as string_upper
Notice that lower() and upper() doesn't take any parameters. And to call those functions you should do like this -
if __name__ == "__main__":
s = input("Enter any string: ")
string_upper(s) # the functions will print, so no need to capture return values
string_lower(s)
For simple conversion like to upper or lower case you can skip function altogether and just do -
if __name__ == "__main__":
s = input("Enter any string: ")
print("Uppercase Output: ", s.upper())
print("Lowercase Output: ", s.lower())
if __name__ == "__main__"block whereupandloware defined? Also why you are trying to print something after thereturnstatement? Maybe you wanted to callstring_upper(string)andstring_lower(string)and inside those functions just print the upper and lower cases instead of returning?returnimmediately returns from the function call, returning the value passed to it, as the value of the function call (which can be assigned, used in an expression, or otherwise used as any other value) - no code afterreturnin the same code block is executed. If you want to print what is about to be returned, print the same value you pass to return - don't call the function again it will cause an infinite loop of recursive calls.