[Python] How to paste code into Python without Python adding extra spaces on the left side

Discussão em 'Python' iniciado por Stack, Janeiro 21, 2025.

  1. Stack

    Stack Membro Participativo

    I am running Python 3.13.1 ( I found this using CMD c:\>python --version)

    When I paste code into Python REPL, Python adds extra spaces at the beginning of every line after the first line

    I wrote this code in Notepad and pasted it into Python.

    if revenue_growth_Q1 > 0:
    RevG1="U"
    else:
    RevG1="D"


    When I copy this code and paste it into Python, the "else:" line is not left justified. Rather, it is offset to the right by several spaces. The code won't run unless I manually delete the spaces to the left of "else:"

    This is what the code looks like after I paste it into Python

    if revenue_growth_Q1 > 0:
    RevG1="U"
    else:
    RevG1="D"


    I'd like to find a way to paste the code so that it aligns in Python with the "else" line left justified (no spaces before else:)

    Continue reading...

Compartilhe esta Página