Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

I'm not sure what is going wrong...

+4 votes
asked Mar 11 by Joey (540 points)
Ok guys and gals, I've been teaching myself python and I've been giving myself little projects here and there to try and help learn and I have been working on this program that will eventually be a Dungeons and Dragons DM/Player tool. That part is irrelevant to this, I have come across the chapter on copy and paste bugs (some minor heading in section 4) and thought that I would try some attention to detail copy and paste work on this new program. So, in my enthusiasm, I believed it would be a good idea to try and copy the body/face user-defined functions and input them instead of the final face of my little skittish awakening program. I can't get the user-defined functions to call and run, and I could really use some advice on how to resolve this issue.

#figure head and body user defined functions:

def human_head():
    print('   ||||| ')
    print("   (O.O) ")
    print('     >' )
    print('   ooooo')

def print_figure(face):
    face()  # Print the face
    print('     |')
    print('   --|--')
    print('  /  |  \\')
    print('@    |    @')
    print('     |')
    print('    /|\\')
    print('   @   @')
#This begins my code, the face and body are borrowed from a zybook for CYB class.

initial_greeting = input('*')
#the poo inputs were simply breaks where I pressed enter to cycle through them.
#what would you input if you were talkin to this lil guy?
print("  ____  ")
print("<(o.o )>")
poo = input()
print("  ____  ")
print("<( o.o)>")
poo1 = input()
print("  ___   ")
print("<(o.o)> ")
poo2 = input()
print("  ___   ")
print("<(-.-)> ")
poo3 = input()
#did I say little? o.O
poo4 = input()
print("HOLY SHIT! You scared me!")
print("Who are you?? Where the hell did you come from?!")
#notation to let the user know to input data
first_name = input()
last_name = input()

print("Well, my apologies for my language. It's very nice to meet you,", first_name, last_name,".")

#notations to the user
print("I am SAM. Well that is untrue. I am SAM's testing module.")
print("My creator, Joey, uses my module as a battlefield against bugs for SAM's code.")
print("Sometimes it gets me down, but then I remember what Joey told me in the beginning:")
print("'Your code is always going to be stronger, because I perfect the code with YOU first'")
print("Now then, a side note from Joey: When ever you see an astrik (*), this code requires input")
print("A double astrik (**) means that I am at the end of my current code, and if you hit enter my window will close")
print("Since my code is very new and my creator is very new, you may simply press enter, as you did above, until the next text appears")
print("Now that that's been said, what would you like to do now,", first_name,"?")

#userInput1. I wonder if an array can be set up? an array for names?
#I wonder how well this is gonna go over XD
#We shall certainly find out.
userInput1 = input()

print(userInput1,"? Well that sounds like hella good fun!")

#ddb is doodoobutt, which is what I will be using to keep the window open until I hit enter at the end
# #Rick-tastic '100 years, Morty'
ddb = input()

__________________ that's the end of the program.

I've tried everything I know to try but the only things that got pasted were the user defined functions themselves. And the only thing I had to add/change was replace two short lines of code with two calls to those functions. I've even tried putting the function calls inside of func() and print() statements...

1 Answer

0 votes
answered Mar 16 by Peter Minarik (55,660 points)

Try it like this:


A bit more details

When you want to call a function, you have to provide the parenthesis after the function name, e.g.: print_figure(). However, when you do not want to call the function itself, just want to pass a function as an argument, you must not call the function, i.e. must not include the parenthesis after the function name, hence there aren't any parentheses after human_head.
commented Mar 16 by Joey (540 points)
I greatly appreciate it. I can't believe I overlooked such a simple mistake...
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.