I'm currently working my way through "Learn Python the Hard Way" and got to the first exercise about functions. It's simply creating a few functions and printing them out like in the previous examples in the book`.
Code:
def print_two(*args):
arg1, arg2 = args
print("arg1: %r, arg2: %r" % (arg1, arg2))
def print_two_again(arg1, arg2):
print("arg1: %r, arg2: %r" % (arg1, arg2))
def print_one(arg1):
print("arg1: %r" % (arg1))
def print_none():
print("I got nothing.")
print_two("Zed","Shaw")
print_two_again("Zed","Shaw")
print_one("First!")
print_none()
Output in cmd:
C:\Users\[USER]\Google Drive\Python\Learn Python the Hard Way>python ex18.py
arg1: 'Zed', arg2: 'Shaw'
arg1: 'Zed', arg2: 'Shaw'
arg1: 'First!'
I got nothing.
I want to play around a bit with this, so instead of just giving me the above four lines when I run it, I want to be able to input the name of the function and then return the result. I tried with the following, but maybe I just don't understand how Python works?
x = input("> ")
print(x)
I'm not quite sure on the terminology but it would give me the following in cmd:
C:\Users\[USER]\Google Drive\Python\Learn Python the Hard Way>python ex18.py
> print_none() # This is something I write myself
I got nothing.