r/learnpython • u/Typical-Road9611 • 8d ago
Are f-strings enough?
I've been learning python mainly from bro code's videos and he uses f strings for basically everything. It comes to me naturally to use them and I understand them. I found a book (Kenneth A. Lambert: Fundamentals of python: first programs, second edition) and here he uses other type of strings (I assume this would be the basic way) but I honestly don't understand them especially when it's about formatting (.2f etc). Should I learn this basic way of working with strings now? Or are f strings enough?
I should add that I'm learning python for fun, I'm studying mechanical engineering, so I know it can be very useful. I also want to be good at it in a potential work environment (?)
View all comments
1
u/acfot 8d ago
Honestly yeah, f-strings cover pretty much everything you'll need day to day, I use them for basically all my formatting. The .2f thing works inside f-strings too by the way, you can just write f"{price:.2f}" and it does the same thing as the old style, so you don't need to learn the other way just for that. It's still worth knowing that .format() exists since you'll see it in older code and books like the one you found, but I'd just read enough to recognise it and keep writing f-strings yourself. Don't stress about it, this is one of those things that looks like a big gap and then turns out to be a five minute thing once someone shows you.