+ 4

[Solv✌d]Why does output indent from line 2

https://code.sololearn.com/cR281e4A1TB4/?ref=app

24th Apr 2020, 6:35 AM
Oma Falk
Oma Falk - avatar
7 Respostas
+ 9
Simply set : sep = "\n" And remove the previous +"\n" before.
24th Apr 2020, 7:10 AM
Théophile
Théophile - avatar
+ 5
print puts spaces between the the strings passed as arguments thus print('a', 'b', 'c') outputs 'a b c'. So print(*['foo\n', 'bar']) outputs 'foo\n bar' and the space between does the job of indentation
24th Apr 2020, 6:50 AM
Mahmud Nabil
Mahmud Nabil - avatar
+ 4
If I get it right so it's a list which you open with the * and each index is separated with a space from the last one except for the first one so it starts only from the second line
24th Apr 2020, 6:45 AM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 4
Perfect! All answers were great thank you all
24th Apr 2020, 7:12 AM
Oma Falk
Oma Falk - avatar
+ 2
24th Apr 2020, 6:59 AM
Oma Falk
Oma Falk - avatar
+ 2
Default value for sep parameter of print is ' ' just override it to '', print(........, sep = '')
24th Apr 2020, 7:11 AM
Mahmud Nabil
Mahmud Nabil - avatar
+ 1
Your welcome
24th Apr 2020, 7:13 AM
Eliya Ben Baruch
Eliya Ben Baruch - avatar