Skip to content

Instantly share code, notes, and snippets.

@Codehunter-py
Created March 12, 2022 17:14
Show Gist options
  • Select an option

  • Save Codehunter-py/d264e146e371b1dd2ef273275223899a to your computer and use it in GitHub Desktop.

Select an option

Save Codehunter-py/d264e146e371b1dd2ef273275223899a to your computer and use it in GitHub Desktop.
The transform_comments function converts comments in a Python script into those usable by a C compiler. This means looking for text that begins with a hash mark (#) and replacing it with double slashes (//), which is the C single-line comment indicator. For the purpose of this exercise, we'll ignore the possibility of a hash mark embedded inside…
@zdrj-me31
Copy link

zdrj-me31 commented Aug 6, 2023

just go ahead with re.sub(r'#+", r"//", line_of_code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment