
Here's a very readable way to concatenate strings using "+=" on lists:
l = [] l += ['abc'] l += ['abc'] l += ['abc'] l += ['abc'] s = ''.join(l) s 'abcabcabcabc'
Probably not exactly what Paul had in mind, but it's beginners friendly. The string version, with O(N²) timing, reads like this:
s = '' s += 'abc' s += 'abc' s += 'abc' s += 'abc' s 'abcabcabcabc'
BTW: I think the above is a great example to teach beginners that choosing the right algorithm is rather important when it comes to dealing with large data sets. It's also a good example of why O(N²) isn't necessarily bad for small data sets. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Experts (#1, Mar 22 2020)
Python Projects, Coaching and Support ... https://www.egenix.com/ Python Product Development ... https://consulting.egenix.com/
::: We implement business ideas - efficiently in both time and costs ::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 https://www.egenix.com/company/contact/ https://www.malemburg.com/