+ 4

List Problem

I want to extract the content of an inner list but I keep getting a newline print after each iteration. End='' doesn't work, sep='' likewise. Please how do I tell tell Python to print on another line only when the content of the list is finished? https://code.sololearn.com/cat449bXe273/?ref=app

18th Jun 2020, 3:08 PM
Tomiwa Joseph
Tomiwa Joseph - avatar
7 odpowiedzi
+ 3
import numpy as np name = [['0','-','-','-'], ['0','0','0','0'], ['0','-','-','-']] q = np.rot90(name,-1) print(q) print() for i in q: print(i) for i in q: for j in i: print(j,end='') print()
18th Jun 2020, 3:20 PM
Deepak
Deepak - avatar
+ 3
The print() after the print(whatever,end='') works magic. Deepak thanks man. Jay Matthews thank you
18th Jun 2020, 9:09 PM
Tomiwa Joseph
Tomiwa Joseph - avatar
+ 2
Waoh! Thanks guys. But can something like this be done without Numpy???
18th Jun 2020, 3:26 PM
Tomiwa Joseph
Tomiwa Joseph - avatar
+ 1
You can do like that even
18th Jun 2020, 3:21 PM
Deepak
Deepak - avatar
+ 1
Well Yes you can do it also
18th Jun 2020, 3:46 PM
Deepak
Deepak - avatar
+ 1
q = [['0','-','-','-'], ['0','0','0','0'], ['0','-','-','-']] print('[',end='') for i in range(len(q)): if i==len(q)-1: print(q[i],end=']') print() break print(q[i]) print() for i in q: print(i) for i in q: for j in i: print(j,end='') print()
18th Jun 2020, 3:46 PM
Deepak
Deepak - avatar
+ 1
Anytime😊 keep coding
19th Jun 2020, 5:27 AM
Deepak
Deepak - avatar