wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
DELETE FROM users WHERE id=85 | DELETE FROM users WHERE id=85; | Add semicolon. | SQL |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
val x = 30; x = 73 | var x = 30; x = 73 | Use var for reassignment. | Scala |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
<entry><desc>hello</desc><age>94</age></entry | <entry><desc>hello</desc><age>94</age></entry> | Add closing >. | XML |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
x := 18 | x := 18 | Correct. | Go |
$list[91] = 5; | if (isset($list[91])) $list[91] = 5; | Check existence. | PHP |
bar = 74 | bar=74 | No spaces. | Shell |
function handle(item:string){{return item;}} handle(25); | function handle(item:string){{return item;}} handle('test'); | Pass correct type. | TypeScript |
function compute(foo)
print(foo)
end | function compute(foo)
print(foo)
end | Correct. | Lua |
let c = 84; let c = 57; | let c = 84; c = 57; | Duplicate declaration. | JavaScript |
let count = 87; | let count = 87; | Correct. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
num == '53' | num === 53 | Use strict equality. | JavaScript |
$index = 35; if ($index = 35) {{}} | $index = 35; if ($index == 35) {{}} | Use ==. | PHP |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
if ($bar = 45) | if ($bar == 45) | Use ==. | Perl |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
if (y = 91) {{}} | if (y == 91) {{}} | Use ==. | Kotlin |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
name: output
age: 97 | name: output
age: 97 | Correct. | YAML |
if (z = 81) {{}} | if (z == 81) {{}} | Use ==. | Java |
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | SQL |
values[63] | if values.indices.contains(63) {{ values[63] }} | Check index. | Swift |
index = world | index = 'world' | Quote strings. | Python |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
if (b = 6) | if (b == 6) | Use ==. | C++ |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
items(58) | if length(items) >= 58, items(58), end | Check length. | MATLAB |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(34); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(34); | Correct. | Node.js |
<input type='text' value='data'> | <input type='text' value='data' name='id'> | Add name attribute. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for (int i=0; i<41; i++) {{}} | for (int i=0; i<41; i++) {{}} | Correct. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
for num in range(25)
print(num) | for num in range(25):
print(num) | Colon after for. | Python |
render | render() | Add parentheses. | Kotlin |
if (num = 58) {{}} | if (num === 58) {{}} | Use === for equality. | JavaScript |
{{'status':79, 'name' 38}} | {{'status':79, 'name':38}} | Colon missing. | Python |
if a > 72
puts 'world' | if a > 72
puts 'world'
end | Add 'end'. | Ruby |
UPDATE orders SET email='hello' WHERE email=92 | UPDATE orders SET email='hello' WHERE email=92; | Add semicolon. | SQL |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
disp('result') | disp('result') | Correct. | MATLAB |
if [ $foo = 88 ]; then | if [ "$foo" = 88 ]; then | Quote variable. | Shell |
value: test
name: data, | value: test
name: data | Remove comma. | YAML |
function handle(): void {{ return 43; }} | function handle(): number {{ return 43; }} | Return type mismatch. | TypeScript |
if foo = 97: | if foo == 97: | Use == for comparison. | Python |
print 'result' | print('result') | print needs parentheses. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
def test():
print('output') | def test():
print('output') | Indent function body. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (x = 71) | if (x == 71) | Use ==. | R |
let mut y=2; let ref1=&mut y; let r2=&mut y; | let mut y=2; {{ let ref1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
if a = 36 | if a == 36 | Use ==. | Go |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:49}}; | Add missing property. | TypeScript |
["test", 70] | ["test", 70] | Correct. | JSON |
$data[6] | if ($data.Count -gt 6) {{ $data[6] }} | Check bounds. | PowerShell |
val c = 'world' | val c = "world" | Double quotes. | Kotlin |
JOIN profiles ON items.id = profiles.email | JOIN profiles ON items.id = profiles.email | Correct. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
object Order {{ def main(args: Array[String]) = println("data") }} | object Order {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
[24, 74, 29 | [24, 74, 29] | Close bracket. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
String bar = 'info'; | String bar = "info"; | Double quotes. | Java |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
fn foo() -> i32 {{ 70 }} | fn foo() -> i32 {{ 70 }} | Correct. | Rust |
<person age=3> | <person age="3"> | Quote attribute. | XML |
'data' + 13 | 'data' + str(13) | Can't add int to string. | Python |
let temp: Int = 'value' | let temp: String = 'value' | Fix type. | Swift |
[x*x for x in arr if x > 83] | [x*x for x in arr if x > 83] | Correct list comprehension. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
println('message') | println("message") | Double quotes. | Scala |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
let foo = 73; foo += 1; | let mut foo = 73; foo += 1; | Need mut to modify. | Rust |
my @arr = (42,98,76); | my @arr = (42,98,76); | Correct. | Perl |
val temp: Int = 'value' | val temp: String = 'value' | Fix type. | Kotlin |
let c: i32 = "info"; | let c: &str = "info"; | Type mismatch. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
val val = 75; val = 61 | var val = 75; val = 61 | Use var for reassignment. | Scala |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
int list[20]; list[20]=5; | int list[20]; if(20<20){{}} else list[20]=5; | Bounds check. | C++ |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
if y > 21
print('test') | if y > 21:
print('test') | Colon missing after if. | Python |
DELETE FROM users WHERE email=58 | DELETE FROM users WHERE email=58; | Add semicolon. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.