
If you don’t like the mentioned solution above, you can use the triple-quote trick to make a block of Python code not run. Command + K then Command + U if you’re on a Mac.Ctrl + K then Ctrl + U if you’re on Windows.To uncomment a block of code, use your mouse to select it and then use the key combination:

Command + K then press Command + C if you’re on a Mac.


To comment on a block of code in Python, you will have to prefix it with # line by line. So how to comment out a block of code in Python? If you have worked with some other programming language like Javascript, Dart … then you will be familiar with / * * / syntax. To comment out a line of code in Python, you can add a # before that line.
