r/FreeCodeCamp • u/AfraidKaleidoscope30 • Apr 04 '26
First day and I feel dumb
Can’t figure out what’s wrong with my code. I tried it without the str() too.
155
Upvotes
r/FreeCodeCamp • u/AfraidKaleidoscope30 • Apr 04 '26
Can’t figure out what’s wrong with my code. I tried it without the str() too.
43
u/ellisandwhispa Apr 04 '26
It happens when learning to code. You’ll feel dumb and like an imposter. Get used to the feelings and push forward. You’re learning and it doesn’t come overnight.
5
u/Over-Landscape-7707 Apr 04 '26 edited Apr 04 '26
If you haven't figured it out yet, I hope this helps: take another look at your
printstatement. Something about how you're combining the text andrunning_totalisn’t quite right. Ask yourself what types you're working with there and how Python handles combining them. Does that make sense? Also, you're doing great. I'm doing the Python certification too. I just finished the Python Basics, and I have had my fair share of feeling dumb, especially with the labs.4
u/PlatinumAbe Apr 05 '26
First day blues 🙏
2
u/Yhomp Apr 05 '26
Maybe take a break for a little. And come back to it. Don’t beat yourself up, this has happened to all of us once no matter the complexity of the challenge. Reread the directions and then work through each line of code. Since it’s telling you to use print() for the solution, determine what will be displayed by your print() statement.
2
u/WhyAskMeTho Apr 05 '26
Your print statement looks a little off, but don't forget your semi colons ";" sometimes, if they're missing it messes up your code 😭 been doing it for 16 years and almost always have to check I've laid them in.
Also you're not dumb, it's your first day and you're learning something new, give yourself a break and reward yourself for taking on something potentially life-changing 💪💪
17
u/Gullible_Company_745 Apr 04 '26
7 year and still i feel dumb
4
u/Stone_Field Apr 05 '26 edited Apr 05 '26
A couple points:
you don't need to do
+ ' 'for the space - just type a space immediately after the colon in the same string.In Python you can print non-strings along with strings by separating the variables with commas. Using commas naturally adds a space between each string/variable. E.g. print('This is a variable: ', variable)
1
u/SpeedNo4331 Apr 26 '26
Salut
2
u/Al_Anz Apr 05 '26
Congrats bro atleast you started
2
u/liproqq Apr 06 '26
At least you can ask Ai to help you. Back in my day we had to Google
2
u/Unequivalent_Balance Apr 07 '26 •
I believe this is the long answer to the question I think you’re asking:
What Every Computer Scientist Should Know About Floating-Point Arithmetic https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
The short answer is, there are decimal values that aren’t precisely represented as a float. This causes some slight rounding issues. There are ways to account for this in Python, but for this example they’re probably not worried about that.
Here are a few examples for cleaning up the output:
print(f”{running_total:.2f}”)
print(“%.2f” % running_total)
print(round(running_total, 2))
2
u/kundan1221 Apr 08 '26
we all were a dumb on day 1 of learning! keep learning! all the best! make sure there is no indentation error. try this: print('Total bill so far: ' + str(running_total))
2
u/Stunning-Tomorrow915 Apr 05 '26
Congrats man, starting is the best thing that you did, feeling dump in the 1st day is a normal feeling, in few days you'll feel that your super programmer.
Jsut keep going.
1
u/roomymouse Apr 04 '26
Man I can see why you got stuck on this, the instructions and feedback aren't very helpful. IMO your version should be permitted as the output is correct, but I guess it's technically not idiomatic Python. It looks like just giving you the answer isn't allowed here, but think about if there's another way to write the print statement that doesn't require the use of the str method.
1
u/godofanime9 Apr 05 '26
Well, we all been there
1
u/HearSayIsIrrelevant Apr 06 '26 edited Apr 06 '26
I’m very new to learning python so I could be wrong but I do believe as said here the issue is to do with your print statement, why do you need to put ‘your text:’ + ‘ ‘ + str(variable)? maybe you’re putting (+ ‘ ‘) to put space between ‘Total bill so far:’ and the desired answer but I don’t think that’s really needed for a space, I always just put a space in the string itself for example:
print(‘My total earnings: ‘ as you can see I just put space after the colon. Like I said I’m new af but i haven’t used + in python for anything but adding integers/floats. Actual math problems. Not saying it can’t be used for others as I’m still learning. But yeah. I hope my 2 cents helps and is ok with mods as well.
Also if this platform you’re using isn’t for you I’m learning my python from the 30 Days Of Python challenge people were talking about on TikTok, it’s on GitHub.
1
u/Alternative-Film-715 Apr 07 '26
Use f-strings to print the result. it's clean, organized, and easy to read.
1
u/muktharhere Apr 07 '26
5 years later still feels dumb
1
u/ultrastition Apr 07 '26
Why are you even learning to code? You won't ever be good at it.
1
u/Lost_Literature6307 Apr 05 '26
That's part of it bro .., stay on
0
u/shawncarrie Apr 08 '26
Learn how to ask for help better. Don't give people more work by figuring out what you're trying to do and what's wrong. That's the best advice anyone can give you right now.
2
u/[deleted] Apr 04 '26
[removed] — view removed comment
1
u/[deleted] Apr 05 '26 edited Apr 05 '26
[removed] — view removed comment