Help me if me if i am wrong , or tell me if its a bug


#1

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

Create a string called product that contains the result of multiplying the float value of float_1 and float_2.

float_1 = 0.25
float_2 = 40.0
product = str(int(float_1*float_2))

error : You set product to: 10 when it should be 10.


#2

There is a big difference between '10' and 10. Unlike JavaScript, which is loosely typed and can recognize numbers written as strings, Python cannot.

product = int(float_1 * float_2)

will produce an integer.

Checking the exercise, we do not need to convert to an integer.

product = float_1 * float_2

I think the instruction, create a string called product may be misworded. If I’m reading this lesson correctly the idea is to demonstrate what happens when we try to concatenate a number with a string.

big_string = "The product was " + product

Traceback (most recent call last):
File “script.py”, line 6, in
big_string = "The product was " + product
TypeError: cannot concatenate ‘str’ and ‘float’ objects

which is kind of confusing given that the lesson is called, ValueError.

big_string = "The product was " + str(product)

The product was 10.0


#3

but they want me to create a string called produce


#4

See my reply above, “I think the instruction, …”.


#5

yeah , so is it a bug ?


#6

Only if you cannot get my answer to work.


#7

that is exaclty what is happening . I wrote a bug report last week and nothing has changed
what should i do


#8

Show us your code, again, please.


#9

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

do you get the code when i write the link ?


#10

No. You will need to paste it into a post. We can see the lesson, but it is in our own workspace so we only see our code, not yours.


#11

i already wrote it from the beginning


#12

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.