16/19, can i have some help here?


I dont understand it ); can I have some help please?


Exercise: type()

Do you already understand that there are different types of things in Python? If we just look at the three types covered in this exercise, we have integers, floats and strings.

Here are brief, simple definitions, you can find more in-depth, precise explanations at the link that I've added below.
- An integer is a whole number, no decimal place.
- A float is a number, and it does have decimal places.
- A string is characters enclosed in quotes.

This exercise it showing you that you can use the built in type() function to find out what type of thing that you are dealing with.

For example, if you want to ask what type of thing that 42 is, you can do that like this:

print type(42)

Which will give you back this answer:

<type 'int'>

The exercise wants you to find out the types of three things - and it wants you to use an integer, a float and a string as your things.

Do you see what is expected of you now?

Extra reading about Built in types in Python.


I still dont get it.
Finally, the type() function returns the type of the data it receives as an argument. If you ask Python to do the following:

print type(42)
print type(4.2)
print type('spam')
Python will output:

Have Python print out the type of an int, a float, and a str string in the editor. You can pick any values on which to call type(), so long as they produce one of each.

Get live, fast support from Codecademy Advisors when you get stuck.
Learn more.
Here's a freebie if you're a bit stuck: print type('I have to push the pram a lot') will cover your str string requirement.

def spam():

print (type("spam"))
print type(42)
print type(3.78)
print type ('int')


When I copy/paste your code, I get this:

To fix that, I would remove the function definition. This exercise doesn't need one. Either that or you could keep it, fix your indentation error and then call your function.


what do you mean by fix your indentation error and also whatever you said so can you please do it and then explain me what you were doing?thx


If you've been working along in Python for a bit, you will have noticed that when you write functions, all of the code that you wish the function to execute must be indented, like this:

def spam():
    print (type("spam"))
    print type(42)
    print type(3.78)
    print type ('int')

If you don't do that then Python will simply not include that code in the function. Fixing your indenting will cure your indentation error.

It won't get you a pass though. As you will also have learned about functions, they just sit there and do nothing unless you call them. In your example that would be accomplished like this:


In this exercise, you are learning about the built-in function type(), there is no requirement for you to create a function yourself, so you could just delete the def spam(): completely.