wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
while b > 31
b -= 1 | while b > 31:
b -= 1 | Colon missing after while. | Python |
os.sqrt(56) | import os
os.sqrt(56) | Import module first. | Python |
DELETE FROM orders WHERE id=83 | DELETE FROM orders WHERE id=83; | Add semicolon. | SQL |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<note><desc>test</desc><name>79</name></note | <note><desc>test</desc><name>79</name></note> | Add closing >. | XML |
{{"name":"info" "status":16}} | {{"name":"info", "status":16}} | Add comma. | JSON |
class User {{ int num; }}; | class User {{ public: int num; }}; | Make public. | C++ |
a > 28 & b < 40 | a > 28 and b < 40 | Use 'and' not '&'. | Python |
$values[47] | if ($values.Count -gt 47) {{ $values[47] }} | Check bounds. | PowerShell |
[13, 7, 35 | [13, 7, 35] | Close bracket. | Ruby |
function foo(): void {{ return 27; }} | function foo(): number {{ return 27; }} | Return type mismatch. | TypeScript |
JOIN products ON users.id = products.email | JOIN products ON users.id = products.email | Correct. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
function handle() {{ echo 'data'; }} | function handle() {{ echo 'data'; }} | Correct. | PHP |
for (int i=0; i<52; i++) {{}} | for (int i=0; i<52; i++) {{}} | Correct. | Java |
<person age=93> | <person age="93"> | Quote attribute. | XML |
let y: number = 'value'; | let y: string = 'value'; | Fix type. | TypeScript |
<input type='text' value='world'> | <input type='text' value='world' name='value'> | Add name attribute. | HTML |
val item: Int = 'data' | val item: String = 'data' | Fix type. | Kotlin |
let val = 'world' | let val = "world" | Double quotes. | Swift |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
def baz(b):
return b + 1 | def baz(b):
return b + 1 | Correct. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(74); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(74, () => console.log('listening')); | Add callback. | Node.js |
if (z = 34) {} | if (z == 34) {} | Use ==. | Dart |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
SELECT * FROM items WHRE age=41; | SELECT * FROM items WHERE age=41; | Fix WHERE. | SQL |
function test() {{
return
{{key:'value'}}
}} | function test() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
switch(val){{ case 68: break; }} | switch(val){{ case 68: break; default: break; }} | Add default case. | Java |
UPDATE orders SET status='output' WHERE role=11 | UPDATE orders SET status='output' WHERE role=11; | Add semicolon. | SQL |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
if (data = 98) | if (data == 98) | Use ==. | R |
list[74] | if (length(list) >= 74) list[74] | Check length. | R |
var x = 86; | var x = 86; | Correct. | Dart |
if (y = 39) {{}} | if (y == 39) {{}} | Use ==. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
if (data = 42) {{}} | if (data === 42) {{}} | Use === for equality. | JavaScript |
int foo = 'world'; | String foo = 'world'; | Type mismatch. | Dart |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
90z = 10 | z90 = 10 | Variable cannot start with digit. | Python |
x := 51 | x := 51 | Correct. | Go |
name: value
age: 23 | name: value
age: 23 | Correct. | YAML |
["value", 3] | ["value", 3] | Correct. | JSON |
if ($temp = 51) | if ($temp == 51) | Use ==. | Perl |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(77); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(77); | Correct. | Node.js |
var x int | var x int | Correct. | Go |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
arr(81) | if length(arr) >= 81, arr(81), end | Check length. | MATLAB |
'world' + 95 | 'world' + 95.to_s | Convert int. | Ruby |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
if temp = 14 | if temp == 14 | Use ==. | Go |
function process(index:string){{return index;}} process(31); | function process(index:string){{return index;}} process('message'); | Pass correct type. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
val num = 'message' | val num = "message" | Double quotes. | Kotlin |
print('data') | print('data') | Correct. | R |
value: data
title: test, | value: data
title: test | Remove comma. | YAML |
$arr[4] = 5; | if (isset($arr[4])) $arr[4] = 5; | Check existence. | PHP |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
let foo = 52; | let foo = 52; | Correct. | JavaScript |
yield val | yield val | Correct yield. | Python |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if (bar = 53) {{}} | if (bar == 53) {{}} | Use ==. | Kotlin |
else
print('info') | else:
print('info') | Colon after else. | Python |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
String b = 'value'; | String b = "value"; | Double quotes. | Java |
for (y in list) | for (y of list) | for...in iterates keys. | JavaScript |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
y = 38 | y=38 | No spaces. | Shell |
<br></br> | <br> | Self-closing. | HTML |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
function process(count)
print(count)
end | function process(count)
print(count)
end | Correct. | Lua |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let index = 14; index += 1; | let mut index = 14; index += 1; | Need mut to modify. | Rust |
data[46] | if data.indices.contains(46) {{ data[46] }} | Check index. | Swift |
bar | bar() | Add parentheses. | Swift |
if b = 11: | if b == 11: | Use == for comparison. | Python |
let mut b=4; let ref1=&mut b; let ref2=&mut b; | let mut b=4; {{ let ref1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
class Product {{ int data; }}
obj.data=5; | class Product {{ public int data; }}
obj.data=5; | Make field public. | Java |
object Person {{ def main(args: Array[String]) = println("result") }} | object Person {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
const x; | const x = 26; | Initialize const. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
int[] values = new int[88];
values[88] = 5; | int[] values = new int[88];
if (88 < values.length) values[88] = 5; | Check bounds. | Java |
if (item = 93) | if (item == 93) | Use ==. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:92}}; | Add missing property. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.