Thanks Japhy Bartlett!

[[0] for i in range(5)]

Works! I converted to fit into my routine as:


lens = [[] for i in range(len(catalog2[0]))]     <<---- the new statement
for row in catalog2:
    for col, item in enumerate(row):
        lens[col].append(len(item))
lens = [max(col) for col in lens]
print(lens)

My result is:

[6, 17, 5, 9, 12, 7, 0, 0, 0]          <<--------THAT IS THE CORRECT ANSWER!

Perfect!

Peter Otten
Thanks! Those work also!

Danny Yoo
Thanks for the Documentation on creating multidimensioned lists! Interesting read! And now I know why my first attempts to get multi-dimensions from an equation failed.

Alan Gauld
YUP!

lens = [ [] for n in catalog2[0] ]

Works!
--And greatly simplifies how I first constructed this!
Thanks!

Thanks Everyone! This gets me going again....
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to