# LIST Comprehension

I have this code 👇👇👇 1.n=int(input()) 2.for i in range(n+1): 3. for j in range(11): 4. print(i,"*",j,"=",i*j) 5. print("---------------------") & I want implement the above code in this format n=int(input()) [[print(i,"*",j,"=",i*j) for i in range(11)] for j in range(n+1)] But I'm not getting the last print ("------") statement, how to do? https://code.sololearn.com/cpUTTzzvHmTc/?ref=app

5/5/2020 4:05:02 PM

♤♢☞ 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ☜♢♤10 Answers

New Answern = int(input()) [[print(*(i, "*", j, "=", i * j) if j < 11 else "---------------------") for j in range(12)] for i in range(n+1)] Best I could do...still looking into it though.

I think, most of the Parterre u already know. print("a", 0* "b") -->a print("a", 1* "b") -->ab print("a", True* "b") -->ab print("a", False* "b") -->a print("a", (3==3)* "b") -->ab print("a", (3==4)* "b") -->a print("a", (3==3)* "-------") -->a------- print("a", (3==3)* "/n-------") --> a ------- it is almost same Think as rodwynnejones did. so if i==10 the block is finished and you add the line.

ok...now the "----------" outputs correctly:- n = int(input()) [[print(("{} * {} = {}".format(i, j, i * j)) if j < 11 else "--------------") for j in range(12)] for i in range(n+1)]

rodwynnejones thanks buddy I want to know about what do we call this format and some more details

Oma Falk yeah I understood your explanation & I appreciate it But as it doesn't match to my code So will you give me, your explanation (above one)small snippet so that I can clear my doubt