I have a Python program that takes user input. I store user input a string variable called "userInput". I want to be able to call the string the user entered...
userInput = input("Enter a command: ")
userInput()
From this, I get the error: TypeError: 'str' object is not callable
Currently, I have the program doing something like this:
userInput = input("Enter a command: ")
if userInput == 'example_command':
example_command()
def example_command():
print('Hello World!')
Clearly this isn't a very efficient way to process a lot of commands. I want to make the str obj callable - anyway to do so?