Shortcut key remove or add #comments in python?

example

# # Reproduce the Bug
# from random import randint
# dice_imgs = ["❶", "❷", "❸", "❹", "❺", "❻"]
# dice_num = randint(0, 5)
# print(dice_imgs[dice_num])}

how to remove # beginning of codes just in a using shortcut key? Please help. Thanks.

It should not automatically comment. Mabey try deleting the # then write code and see if the following lines become comments since I cant repro this.

2 Likes

Hi @dnrts good question.

I’d use search and replace (usually CTRL+H) to search for # and replace it with an empty field.

4 Likes

Hi @dnrts another option is to use the Toggle Line Comment Shortcut Key to toggle comment on/off for the current line or selection. (on windows use CTRL+/, or on macOS use CMD+/)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.