Asked about Variables, strings and numbers
Why use join instead of adding strings in a loop?
An answer that works
Strings are immutable, so each + builds a whole new string and copies everything so far. Over many iterations that repeated copying makes the loop much slower. join does it in one pass.
Reading an answer is not being able to give one. The section that teaches this is Variables, strings and numbers, 3 hours of Python.
Learn this properlyAlso asked about Python
What is the difference between a list and a tuple?What is the difference between == and is?What does s[::-1] do?How would you remove duplicates from a list?Why is checking membership in a set faster than in a list?What happens if you use a list as a dictionary key?What is the difference between sorted(x) and x.sort()?What is wrong with def f(items=[])?
All 36 questions on Python