1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] double printing in pycharm

Discussão em 'Python' iniciado por Stack, Setembro 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm writing some recursive functions as part of my homework.

    I wrote this piece of code for printing all binary sequences of length n:

    def binary_sequences_helper(n, sequence):
    if len(sequence) == n:
    print(sequence)
    else:
    binary_sequences_helper(n, sequence + '0')
    binary_sequences_helper(n, sequence + '1')


    def print_binary_sequences(n):
    binary_sequences_helper(n, '')


    print_binary_sequences(1)


    The output in the pycharm shell is

    0
    1
    0
    1


    Instead of just 0 1 when I run exactly the same code in the IDLE or on my friend's computer.

    Any idea what could be the issue?

    Continue reading...

Compartilhe esta Página