r/learnpython • u/Ethere4listic • Jan 23 '24
Am I dumb?
I started learning python 2 days ago and now I cant understand somethings like if i want to make a thousand look like this 1,000 I need to put the function like: print(f{"number:,"}). Is it normal to see it somehow complicated or am I below average iq?
12
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Jan 23 '24
print(f{"number:,"})
print(f"{number:,}")In short, you get used to it.
12
u/jacobvso Jan 23 '24
To be honest, I've been coding in Python for 3 years and I wasn't aware of this trick.
3
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Jan 23 '24
You're looking for the format specification mini-language, then: https://docs.python.org/3/library/string.html#format-specification-mini-language
-20
u/Ethere4listic Jan 23 '24
I'm just better.
3
u/Snoo17309 Jan 23 '24
I’m hoping you’re being facetious here. Anyway, it’s more about learning the reasoning behind what is needed than memorizing formatting—do you know why and all the different ways in which you could/would use f-strings and with what variable types? Pseudo coding and then you can always look it up if there’s some small error in the code. But again, you’ve got to understand why there’s and error logically.
35
u/Vrad_pitt Jan 23 '24
u are just two days in, it's normal that you are not familiar with the language
6
u/anh86 Jan 23 '24
You're only two days in and, presumably, this is your first programming language! It takes time and you have to write a lot of practice code to become proficient. If spend an hour per night writing code (not watching YouTube videos) then maybe in six months you will be a semi-decent programmer. You should have zero expectations about the second day.
5
u/mopslik Jan 23 '24
That's an f-string, using the mini-language specifications. In this case, the colon (:) indicates some formatting specifications follow the value to be displayed (number), and the comma indicates that the thousands separator should be ','. True, it is a bit complex, but that's to keep things concise. For example, let's say you wanted to display a floating-point value with two decimals of accuracy, comma separated, right-aligned. Instead of typing something like
print(value, type=float, decimals=2, separator=",", align="right")(which doesn't work, BTW), you can write this as
print(f"{value:>,.2f}")(which does work). You get used to most of it with experience, and you don't need to memorize all of the options, as you can look things up in the docs if you need to.
3
u/This_Growth2898 Jan 23 '24
Specifically about the issue. In Python, there is almost always "the Pythonic way" of doing this or that - except for string formatting. There are at least 5 different ways to print 2 items in 1 line:
a = "Hello"
b = "world"
print(a, b)
print(a + " " + b)
print("%s %s" % (a, b))
print("{} {}".format(a, b))
print(f"{a} {b}")Probably, I've missed some more. And you know why is it? Because string formatting, though seemingly easy, is a complex task. There's nothing wrong about being confused with it. Even Python developers are confused.
2
u/baubleglue Jan 23 '24
Formatting a text is not something you need to focus on that stage of learning. At least not shortcut formatting options Python has. The easiest way to deal with such types of confusion
Understand the problem
typeyou are facing (find a general term)Find basic tutorials - doesn't mean short. Find the which describes basic features without skipping
Make few exercises
But again, read about string formatting latter, use simpler methods to format output.
2
u/wyltk5 Jan 23 '24
Hey op,
Python like any other programming language is just that, a language. I mean I don’t know German and if I was 2 days into learning German I would be a little lost in even the format of a sentence in their language.
It’s gonna take some time to be able to “know” the language. Take your time and while learning try and learn the “why” behind how something works. It will allow you to understand the language rather than just knowing what to type.
Take notes as you go so you have references to go back on but mainly enjoy the journey!
Cheers
1
u/trust_me_on_that_one Jan 23 '24 edited Jan 23 '24
You don't know what you don't know so don't beat yourself up. We've all been there. Learning Python in the beginning is a rollercoaster with lots of down and some ups, not a straight line. Keep going. Once it clicks you'll feel like you're on top of the world!
1
u/Picatrixter Jan 23 '24
"I started learning python 2 days ago and now I cant understand..." [whatever]. WTF, you a child? Give yourself some time & space, that's how the mind works. First, it's all noise, then you begin to see some patterns, then AHA moments, then habits. Rinse and repeat. Good luck and don't cave in.
1
u/phonic_boy Jan 23 '24
I'm three days in and I can't rememeber most of what I learnt. Everytime I need to convert a string to a whole number I get completely lost.
1
Jan 24 '24
Bro I am now 7-8 years into programming and atleast 4 years into python, still I have to sometimes google such shit. Don't take load. It happens.
1
u/aqjo Jan 24 '24
You’re on a long journey my friend.
It’s similar to learning a human language. You can’t expect to make a hotel reservation and order dinner after studying (French, Italian, Mandarin, etc.) after two days. Take your time. Don’t beat yourself up.
1
Jan 25 '24
I'm about two weeks into learning Python. I probably get about 2 hours a day in. I would say that just the last few days, the beginner level syntax is really starting to click in my brain. It's also helpful to find someone on YouTube who explains it in a way that you understand. I really like Bro Code on YouTube.
1
u/DoubleAway6573 Jan 29 '24
Yes. You are dumb.
And you will be dumb most of your career if you are doing this right.
Nobody know everything. Programing is learning ways to solve problems. and hoy to express those problems and solutions in a "somewhat standard" way. Most of the time i feel like the dumbest man on earth, and then I, like being stuck by a thunder, I have an aha moment and I feel like Einstein in MDMA.
Just get use to it and, if this like to you, keep doing. You bill become better with time.
0
10
Jan 23 '24
[removed] — view removed comment
1
u/ClimberMel Jan 23 '24
Really? How do they represent 1.000 (1 with 3 decimals?
1
Jan 23 '24
[removed] — view removed comment
1
u/ClimberMel Jan 23 '24
Oh, so they switch the commas and decimals. OK, that is easy enough to deal with.
8
u/cyberjellyfish Jan 23 '24
An undergrad in computer science or software engineering takes four years.
You've been at it two days.
For those same programs, the drop rates after programming 101 is drastic. Like half the people not showing up in programming 102 isn't at all unusual. Those classes take a semester.
Programming is hard. It's not something most people have experience with.
Building software is harder.
You're fine.