Print function | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
- 1

Print function

Print A B C D in a list format. When adding \n to create the list. It is creating another line underneath which is blank but coming back as an error. Can anyone help with this?

24th Dec 2020, 7:11 PM
Thomas
5 ответов
+ 5
Thomas , your code just prints A B C D, each in a separate line. Not clear what problem you have.
24th Dec 2020, 8:14 PM
Lothar
Lothar - avatar
+ 1
where is your code ?
24th Dec 2020, 7:28 PM
Ratnapal Shende
Ratnapal Shende - avatar
+ 1
a = 'A \nB \nC \nD' print(a)
24th Dec 2020, 7:57 PM
Thomas
+ 1
1. print(['A',"B',"C','D']) 2. x ='ABCD' z=list(x) print(z) 3.for i in x: print(i) 4.print(f"listformat({x})")#this is joke one
24th Dec 2020, 8:27 PM
Shadoff
Shadoff - avatar
0
# Thomas #is this what you want ?? x="A\nB\nC\nD" print([i for i in x if not i == "\n"]) #output : [ 'A', 'B', 'C', 'D' ]
25th Dec 2020, 6:01 AM
Ratnapal Shende
Ratnapal Shende - avatar