color = "red"
f"I have {5} {color} apples"'I have 5 red apples'
Unit 05
At this point, you have already learned a fair bit about strings, most notably
" or single ' quotes,"Hello 'world'"),"I have " + str(5) + " apples".Strings and numeric objects can actually be combined a lot nicer and with more flexibility. Simply put an f in front of the quotes and directly use numeric objects in your string by enclosing them in curly brackets, like so:
There are plenty of ways that you can use to format the appearance of the strings. You will notice a couple in the lecture material, but if you are interested to learn more, feel free to read Section 7.1.1 of the python documentation on f-strings.
You can loop through strings just like you would expect,
I personally mostly need f-strings. Other string methods that I use regularly are, .find(), .split(), and .lower().
What you have learned so far should cover your needs. If you want to read up more, check out the Chapter Strings of the online course PY4E.