0
How does this happen ?
a = ['bug found', "in line1"] a[1] = "\n" + a[1] for i in a: temp = i.split() print(' '.join(temp)) I have written the above code and am expecting the output as --------------- bug found in line1 --------------- but instead I got the following output ----------------------- bug found in line1 ----------------------- Can anyone give the explanation for this ? And how do I code inorder to get the desired output?
2 Réponses
+ 3
By default split looks for all whitespace characters.
In this concrete example it would work when you use i.split(' ').
If you just want to separate each array entry by a Line I suggest to just add a line break to the print call.
+ 2
THANK YOU Manu_1-9-8-5 . It was so helpful to me.