Home > other >  Beginners ask, who can write a complete program according to the requirements of screenshots of the
Beginners ask, who can write a complete program according to the requirements of screenshots of the

Time:01-07




I write the program (didn't finish writing, not)
TableDate=[[' hello ', 'world', 'word', 'ok'], [' hello1 ', 'world1', 'word1', 'ok1], [' hello2', 'world2', 'word2', 'ok2]]
Def printTable (ok) :
Len colWidths=[0] * (tableDate)
Return colWidths
For I in range (len (colWidths) :
Len colWidths [I]=[0] * (tableDate [I])
Return colWidths [I]
Print (printTable (tableDate))

CodePudding user response:

 table=[[' hello ', 'world', 'word', 'ok'], [' hello1 ', 'world1', 'word1', 'ok1], [' hello2', 'world2', 'word2', 'ok2]] 
Ws=[Max ([len (row [I]) for the row in the table]) for I in range (len (table [0]))]
For r in the table:
Print (f '{r [0] : & gt; {ws [0]}} {r [1] : & lt; {ws [1]}} {r [2] : & lt; {ws [2]}} {r [3] : & gt; {ws [3]}} ')
  • Related