I'm keen to see how f-strings work with the programme I wrote in my previous post. I was advised that they're much easier to work with and less prone to error.
so...
I have a lot of boxes of eggs in my fridge and I want to calculate how many omelettes I can make. each box of eggs contains six eggs and I need four eggs for each omelette.
'to make 25 omlettes, you will need 100 eggs. That means you need to buy 16 cartons of eggs'
'there are 54 eggs in total, this means you can make 13 omlettes with 2 eggs left over'
It's a lot easier to figure out which placeholder represents which variable, so the code is a lot easier to read. I'm also happy to see the code shrink a bit!
Top comments (0)