[Python] Can somebody please explain to me about this line : '\n'.join([f"{n} x {i} = {n*i}"...

Discussão em 'Python' iniciado por Stack, Fevereiro 16, 2025.

  1. Stack

    Stack Membro Participativo

    n= int(input())
    print('\n'.join([f"{n} x {i} = {n*i}" for i in range(1,11)]))


    and why can't I write like below?

    n= int(input())
    for i in range(1,11):
    x = ["{} * {} = {}".format(n,i,(n*i))]
    print('\n'.join(x))

    Continue reading...

Compartilhe esta Página