Use print to print total_cost


#1

https://www.codecademy.com/courses/learn-python/lessons/python-syntax/exercises/numeric-datatypes?action=resume_content_item

I believe I got past this part of the lesson previously, but had issues further on that I could not move past. Even though support said my code was correct, I could not proceed.
I have returned in hopes that things might go more smoothly and I’m getting stuck at 9/14 once again (even though I got past this last time).

I’ve tried several ways to satisfy the program. One issue seems to be that we are asked “What datatype is it?” But we haven’t covered this in the lesson thus far – even though the answer should be clear, we don’t have instructions on how to print “type” or “datatype.”
Here is the latest iteration of my code:


cucumbers = 2 
price_per_cucumber = 3.25 
total_cost = cucumbers * price_per_cucumber 
print total_cost 
print type(total_cost)

This code does produce the results:

6.5
<type ‘float’>

However I get an error message:
Use print to print total_cost.

What is wrong with my code?
What am I doing wrong?
Please advise.


Why is total_cost a float?
#2

I had the same issue. When I changed the number of cucumbers to 3, (I also had 2 cucumbers initially) it suddenly worked. Then I changed it back to 2 and it still worked. So I guess there might be a bug (?)
(and I think the question regarding type is rhetorical)


#3

Interesting.
I found that I was able to move on even though I had the error message.
I reported a bug as another attempt to get a response and hopefully clarify the lesson.
Thanks for your reply


#4

once you pass a checkpoint it isn’t validated again

it asks you what data type it is, the exercise doesn’t ask you to print the data type. Adding additional code will sometimes get you in trouble


#5

So how do you answer what data type it is?

Again, that was only the latest iteration of my code. I didn’t say print every time, but it is unclear how data type is wanted, especially since it isn’t mentioned or discussed up to that point.


#6

its just a reflection question meant for you, to see if you know what data type you are dealing with, i think it is meant to be answered just by using your memory and reflecting on your code. If you don’t know, temporary adding type() to see can be helpful.


#7

So, you don’t actually have to enter anything?
The system was unsatisfied when I stopped at: print total_cost


#8

hm… that should be good enough, that should be the in the bug report


#9

ah, right, thank you!


#10

Okay, thank you.

That was probably not in the bug report, just my clear sense of confusion!
I think I pretty much sent what I typed up above, which I did after trying maybe six variations. I believe I understood it the first time but when it was not accepted I tried ways of expressing the data type.

Thanks again


#11

hey !! I am facing the same difficulty !! I am stuck at 9/14 !! I am unable to pass through it !! I have typed print total_cost but it is still showing an error message !! also in what way do I specify the data type is ‘float’ !! they have not specified it !! if you find a solution to this problem , then please let me know ASAP!!