Missing Expected Result

I am trying to run this file from Learning Python's book The Hard Way using the python ex18.py command, but it does not output anything. What's wrong?

# this one is like your scripts with argv
def print_two(*args):
    arg1, arg2 = args
    print "arg1: %r, arg2: %r" % (arg1, arg2)

# ok, that *args is actually pointless, we can just do this
def print_two_again(arg1, arg2):
    print "arg1: %r, arg2: %r" % (arg1, arg2)

# this takes just one argument
def print_one(arg1):
    print "arg1: %r" % arg1

# this one takes no arguments
def print_none():
    print "I got nothin'."  
+3
source share
4 answers

Since this file does not actually call any functions, do not output anything.

This file simply defines four functions and then does nothing with them. :)

Try adding calls to print_none, print_oneetc:

print_none()
print_one("hello")
print_two("hello", "world")
print_two_again("hello", "world")
+8
source

Most likely, you do not call the function after they are defined.

Following these methods. Name them, for example:

print_none()

You can put this at the end of the file, or if you import the file into the shell, you can simply enter it right after.

+3
source

, , .

+2

C Java, " , ".

0

All Articles