results=[]
for x in range(5):
results += '$'
print(results)
output : ['$', '$', '$', '$', '$']
This code behaves differently from typical +=
operator. As you can see here it has generated a list with the $
string inside it.
It's not equal to what we think results = results + '$'
. This code will throw you an error.
Can you describe what is going on this code?