import sys

from bs4 import BeautifulSoup
from requests import get, codes


def match_soup_class(target, mode='class'):
    def do_match(tag):
        classes = tag.get(mode, [])
        return all(c in classes for c in target)
    return do_match


def main():
    if len(sys.argv) == 1:
        p = 1
    else:
        p = int(sys.argv[1])

    url = 'https://projecteuler.net/problem=%d' % p
    r = get(url)
    if r.status_code != codes.ok:
        print('[url request failed] ', url)
        return
    soup = BeautifulSoup(r.text, 'html.parser')
    for content in soup.find_all(match_soup_class(['problem_content'])):
        print(content.text)


if __name__ == '__main__':
    main()

import sys

from bs4 import BeautifulSoup
from requests import get, codes


def match_soup_class(target, mode='class'):
    def do_match(tag):
        classes = tag.get(mode, [])
        return all(c in classes for c in target)
    return do_match


def main():
    if len(sys.argv) == 1:
        p = 1
    else:
        p = int(sys.argv[1])

    url = 'https://projecteuler.net/problem=%d' % p
    r = get(url)
    if r.status_code != codes.ok:
        print('[url request failed] ', url)
        return
    soup = BeautifulSoup(r.text, 'html.parser')
    print("'''")
    print('Problem %d' % p)
    for content in soup.find_all(match_soup_class(['problem_content'])):
        print(content.text)
    print("'''")

if __name__ == '__main__':
    main()

ADD comment for python file
ADD comment for python file

  import sys
  
  from bs4 import BeautifulSoup
  from requests import get, codes
  
  
  def match_soup_class(target, mode='class'):
      def do_match(tag):
          classes = tag.get(mode, [])
          return all(c in classes for c in target)
      return do_match
  
  
  def main():
      if len(sys.argv) == 1:
          p = 1
      else:
          p = int(sys.argv[1])
  
      url = 'https://projecteuler.net/problem=%d' % p
      r = get(url)
      if r.status_code != codes.ok:
          print('[url request failed] ', url)
          return
      soup = BeautifulSoup(r.text, 'html.parser')
+     print("'''")
+     print('Problem %d' % p)
      for content in soup.find_all(match_soup_class(['problem_content'])):
          print(content.text)
- 
+     print("'''")
  
  if __name__ == '__main__':
      main()
  
ADD comment for python file
## Code Before:
import sys

from bs4 import BeautifulSoup
from requests import get, codes


def match_soup_class(target, mode='class'):
    def do_match(tag):
        classes = tag.get(mode, [])
        return all(c in classes for c in target)
    return do_match


def main():
    if len(sys.argv) == 1:
        p = 1
    else:
        p = int(sys.argv[1])

    url = 'https://projecteuler.net/problem=%d' % p
    r = get(url)
    if r.status_code != codes.ok:
        print('[url request failed] ', url)
        return
    soup = BeautifulSoup(r.text, 'html.parser')
    for content in soup.find_all(match_soup_class(['problem_content'])):
        print(content.text)


if __name__ == '__main__':
    main()

## Instruction:
ADD comment for python file
## Code After:
import sys

from bs4 import BeautifulSoup
from requests import get, codes


def match_soup_class(target, mode='class'):
    def do_match(tag):
        classes = tag.get(mode, [])
        return all(c in classes for c in target)
    return do_match


def main():
    if len(sys.argv) == 1:
        p = 1
    else:
        p = int(sys.argv[1])

    url = 'https://projecteuler.net/problem=%d' % p
    r = get(url)
    if r.status_code != codes.ok:
        print('[url request failed] ', url)
        return
    soup = BeautifulSoup(r.text, 'html.parser')
    print("'''")
    print('Problem %d' % p)
    for content in soup.find_all(match_soup_class(['problem_content'])):
        print(content.text)
    print("'''")

if __name__ == '__main__':
    main()
