Could someone tell me whats wrong with my code, Please


#1

I dont know whats wrong with my code


#2

Hi there coremaster!

When you are using functions there are two major steps that you can't skip out on or the code won't show in the console.

First off, you define a function using the keyword def(define) and don't make the mistake of thinking that Def is the same as def, it's not. Python is case sensitive!

Second, in order to use or call the function, you have to retype the name of the function after you have finished filling the function with code. If you don't call it, it won't do anything. You'll just have a block of code sitting doing nothing!
And we don't want that...

Here's a little bit of code to help you understand:

def a_function():
print("I'm being printed because the function I'm sitting in IS being called!")
a_function()

def b_function():
print("I'm not being printed because I'm NOT being called... :frowning: ")

I hope this helps you. If you have any other question don't hesitate to ask!


#3

The issue is, that you try to put a string into the brackets after the def. You actually only put a variable name, which serves as a placeholder. Whenever you call the function, you will have to tell what you want to insert into the variable you defined in the function.

Lets say you create a function called "behemoth", with food as a variable:

def behemoth(food): #food tells the function that you have one placeholder
    print "The behemoth ate", food #The program doesn't know what the behemoth actually ate

behemoth("fish") #Here you call the function and insert "fish" into the gap

This will print "The behemoth ate fish" on your screen :smiley:

If you got annoyed of the explanation, here's your error:

delete the "" around city and it will work fine :wink:


#4

thank you for your input but a friend helped me earlier but i really appreciate it :grin:


#5