String concatenation combines separate strings into one string. Use it when a small number of text fragments must become a readable result, such as a display label or a sentence. section 2.3 section 2.3.4
# initial input fruit0 = "apple" fruit1 = "banana" fruit2 = "orange" # desired output liked_fruits = "apple, banana, orange"
Joining three fruit strings with comma-space separators produces one display string: "apple, banana, orange". section 2.3
Choose the joining technique according to the number and organization of the strings:
- Use concatenation operators for a small number of strings. section 2.3.4
- Prefer f-strings when related values and expressions need to be brought together clearly. section 2.3.4
- Use join when individual strings are stored in an iterable or when many strings must be combined. section 2.3.4 section 2.6
Building a numbered label
for num_i in range(len(prime_numbers)): num_pos = num_i + 1 num = prime_numbers[num_i] print("Prime Number #" + str(num_pos) + ": " + str(num)) section 1.4.1









