I kept getting the TypeError code, I tried all the different layouts of the code as I could think of and still had no luck, I finally gave in and got the solution, only to find I was correct but needed to include a space at the end of the string, so rather than it being: “The product was” followed by the rest of my code, it should have been: "The product was ". Hope this helps anyone encountering this problem.
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.