[Python] Newline makes empty spaces in front of the second line in a set, need to remove them

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

  1. Stack

    Stack Membro Participativo

    (I'm using Python for this)

    My code keeps outputting in a weird way where, after the first line in a set of two outputs, the second will have a space before it.

    print('{}\n'.format(password))

    print('First password: {}\n'.format (first_password),
    'Second password: {}\n'.format(second_password))

    print('Number of characters in {}: {}\n'.format(first_password, x),
    'Number of characters in {}: {}'.format(second_password, y))


    I've got the input in place and such, but the second line in each set has a space in front of it, which messes up the synergy. I'm fairly certain the newlines are to blame, but I don't know how to fix the issue.

    You entered: Red Biggie 7

    First password: Red_Biggie
    Second password: 7Biggie7

    Number of characters in Red_Biggie: 10
    Number of characters in 7Biggie7: 8


    I tried messing with syntax, moving the lines around, nothing worked. I tried printing them on separate lines but they were spaced out too much to be valid for what I need to do. I don't have much time left to get this done so help would be greatly appreciated!

    Continue reading...

Compartilhe esta Página