Text Generator
Text Generator > Use Cases >Python bug fixer

Python bug fixer

There's a number of ways of structuring the prompt for checking for bugs. Here we add a comment suggesting that source code is buggy, and then ask codex to generate a fixed code.

Example input

  • ##### Fix bugs in the below function ### Buggy Python import Random a = random.randint(1,12) b = random.randint(1,12) for i in range(10): question = "What is "+a+" x "+b+"? " answer = input(question) if answer = a*b print (Well done!) else: print("No.") ### Fixed Python

Example real generated results

  • star

    A: def test() : n=1+1+2+3+4+5+6+7+8+9+10+11 + 12 *2**5 l=range((n-2),n+1) r=[random.choice for _ in x:l[_r]-1]*2/len(x) return "" class A: @staticmethod def make_dummy_thing () -> str # no docstring needed here """Make dummy thing""" d="Dummy Something..." A().make_dummy_thing() s=a() e="" b={1:2} g=s+a h=b+g p=g/h (o=p[0],(p[1]+p[2])) (s=e) ^^^^^^^^ No match found

  • star

    ## def main() { global numquestions; #numQuestions=[0]; for k in [1000]: questions=input().split() answers=[] for qn in questions: try: ansid=qn; ## Answer id will be stored at position aname={} Answers[id]={ansid:""+anames[i] : [] } except IndexError: pass while((answer=="0" or "").upper()!='N' ) and ((answers[k][0]==' '))==0: continue toadd=''; """ */ sys.exit() ''' return 0; main() A: def test () import time totalTime=0 global lastTime; //set by user when asked what he did first

  • star

    from collections import defaultdict as dc ##--------------------------------------------------------------------------------------------------// def getAllThePrices() : #Get all prices for each item ## All values should be between 1 and 12 return { 'one':dc( {'item' }, 'strawberry': {"apple"=>[{"price"=>5, "name"=>"straw", "sku_name":"srs"}, ["price"=>0, "name""=>"sbrd", "skou_name" =>"SBRD"], ]}}, 'brown rice'=>{'total_price'=>'2000000'}, }

  • star

    def main(){ questions=["What are 12 plus 1", What Are 15 Plus 3", "What ARE 9+3 AND 2+9 +2" and more than that"] for qstn as : #questions[0]+=qstn; #print 'Question:'+str('{}'+'') c1=[] } n=2 ##main() '''I have tried to solve this on stackoverflow but was not able. return '' ------------ def solution( ) { try: x=Random().randrange ( 1, 100 ) bx=x * answers[-1] except ValueError: pass """ import sys args="" temp=[] while 1: tmp={} global arr; myname=temp[1]

try it yourself: Text Generator Playground - Python bug fixer