That would have been actually very easy to spot if you had paid attention to the right panel. Writing “The product was10.0” isn’t quite nice in general, nor pleasing to the eye.
I agree, I should have noticed it a lot sooner, I usually do leave a space and thought I had, but obviously I had missed it somehow. And when looking through my code, it was hard to spot the missing space (I don’t usually pay close attention to the right panel)
2 posts were split to a new topic: How to Get Rid of the Decimal Place Here?
2 posts were split to a new topic: Why is
str() Necessary for Concatenation Here?
Actually, the commands
string_num = “7.5”
will not give the value of 7. Instead, it will show ValueError: invalid literal for int() with base 10: ‘7.5’.
I do not know why it is. But I figured out how to solve it. Do this instead:
string_num = “7.5”
I got the same ValueError as well.
I continued to receive error, which stated the my statement read : The product was 10.0 we wanted it to say “The product was 10”- I had the proper spacing in my typing and all that, yet when I clicked the solution the only thing that was changed was i needed line 3 to be empty…my question is, did they want me to get rid of the “.” in the float 10.0 and make it an integer? If so, what does making line 3 blank have to do with changing it 10.0 to 10? Am I missing something?
float_1 = 0.25
float_2 = 40.0
product = float_1 * float_2
big_string = "The product was " + str(product)
So here was the correct answer for this problem. I had the same exact thing the only difference was that I had not skipped a line in the code. Can someone explain why I kept getting error message?
Does programming always make a person feel so stupid? Haha thanks for the solution. It was so easy, and I knew it, my mind was just stuck on X and it obviously should have been focused on Y.
as beginner programmer, its so easy to go down the rabbit hole (and then complete in the wrong direction)
i think its quite common for people who start with programming, its not just about code, its also about a mindset, understanding the computer and so forth.
im so lost. there is all the proper spacing in my code, yet its STILL telling me my answer is " The product is10.0 " and ive rewritten my line of code so many times only for it to give the same error!! whats going on here?
please see this topic:
Without the code, its really difficult (nearly impossible) to tell what is wrong
ive seen many others not share the full code yet received replies like it was nothing. im stuck at the exact same place everyone else is. so y is that not good enough?
they also dont get mods telling them how to ask for help.
the full code makes helping even easier, but only the relevant part is also fine.
the topic i shared is in at least 120 post, so its quite commonly used, and there is a reason we use it. Really allows us to help learners better, that topic (how to ask good questions) was made based on years of experience
i was in other threads and never saw that one being posted in a direct reply to another. here i am thinking someone is gonna actually help, yet im being directed on how to ask for it.
3 months later and i too have the same issue with the same code. i look at the solution and everything is identical. so how come my print is showing as “The product was10.0” and not “The product was 10”
I have been on this forum for years, and seen many super users (TL3), moderators and others ask clarification questions so we can help you better.
what is the problem to share the exercise url and your code?
@harleyquinn420, if I come on to a forum and say something like,
“I typed everything right, but it is telling me my answer is ‘xyz’”
How can you know what I typed? How can you know what the exercise was?
There is no way to answer a question like that.
If you help us, we will try to help you.
Regardng the ‘Value Error’ exercise, I found it to be confusing and the so-called proper response to be incorrect. I, too, typed everything just as it is displayed and kept receiving a syntax error message. I finally just typed in the following and the error message went away.: big_string = “The product was 10”.
This is not the way the lesson detailed setting the variable values (i.e. quotation marks are not used). I also tried to convert product to a string as in the example to no avail.
I also found no responses addressing this specific issue. Furthermore, most of the responses to questions asked are unclear and only lead to more questions – specifically, what the heck are you saying that actually answers my question in a clear, concise manner. If you do not know the answer, say as much. The online help is sorely lacking.
I would like someone to explain to me in clear, concise, coherent and complete sentences why my ultimate response to the exercise is correct and cause the error message to go away. I would also like to know an alternative response that would have worked. Once again, my response to the exercise is big_string = “The product was 10”. I should have been able to enter, big_string = The str(product) was product. What this should do is change “product” to a string and placed the value of ‘product’ in the place of X.