What does print(… sep='', '\t' ) mean?

前端 未结 4 2026
逝去的感伤
逝去的感伤 2020-12-08 11:06

I am having a bit of trouble trying to find an answer to this. I would like to know what the syntax sep=\"\" and \\t means. I have found some infor

4条回答
  •  爱一瞬间的悲伤
    2020-12-08 11:42

    sep='' ignore whiteSpace. see the code to understand.Without sep=''

    from itertools import permutations
    s,k = input().split()
    for i in list(permutations(sorted(s), int(k))):
        print(*i)
    

    output:

    HACK 2
    A C
    A H
    A K
    C A
    C H
    C K
    H A
    H C
    H K
    K A
    K C
    K H
    

    using sep='' The code and output.

    from itertools import permutations
    s,k = input().split()
    for i in list(permutations(sorted(s), int(k))):
        print(*i,sep='')
    

    output:

    HACK 2
    AC
    AH
    AK
    CA
    CH
    CK
    HA
    HC
    HK
    KA
    KC
    KH
    

提交回复
热议问题