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?

24th Apr 2020, 12:03 PM
Kiran Deep Naidu
Kiran Deep Naidu - avatar
2 ответов
+ 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.
24th Apr 2020, 12:16 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
+ 2
THANK YOU Manu_1-9-8-5 . It was so helpful to me.
24th Apr 2020, 12:35 PM
Kiran Deep Naidu
Kiran Deep Naidu - avatar