wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (x = 18) | if (x == 18) | Use ==. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int[] values = new int[40];
values[40] = 5; | int[] values = new int[40];
if (40 < values.length) values[40] = 5; | Check bounds. | Java |
// comment | /* comment */ | Use /* */. | CSS |
for (int i=0; i<9; i++) {{}} | for (int i=0; i<9; i++) {{}} | Correct. | Java |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let b: number = 'message'; | let b: string = 'message'; | Fix type. | TypeScript |
if ($z = 74) {{}} | if ($z -eq 74) {{}} | Use -eq. | PowerShell |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
[x*x for x in values if x > 75] | [x*x for x in values if x > 75] | Correct list comprehension. | Python |
val result: Int = 'value' | val result: String = 'value' | Fix type. | Kotlin |
list[1] | if list.indices.contains(1) {{ list[1] }} | Check index. | Swift |
<input type='text' value='value'> | <input type='text' value='value' name='value'> | Add name attribute. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(95); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(95); | Correct. | Node.js |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
function bar(z:string){{return z;}} bar(70); | function bar(z:string){{return z;}} bar('test'); | Pass correct type. | TypeScript |
function baz(): void {{ return 54; }} | function baz(): number {{ return 54; }} | Return type mismatch. | TypeScript |
85temp = 10 | temp85 = 10 | Variable cannot start with digit. | Python |
var index int = 'data' | var index string = 'data' | Type mismatch. | Go |
let item = 48; | let item = 48; | Correct. | JavaScript |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
class Order {{ int item; }}; | class Order {{ public: int item; }}; | Make public. | C++ |
UPDATE items SET age='test' WHERE status=85 | UPDATE items SET age='test' WHERE status=85; | Add semicolon. | SQL |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
{{"name":"message",}} | {{"name":"message"}} | Remove trailing comma. | JSON |
def process(val):
return val + 1 | def process(val):
return val + 1 | Correct. | Python |
if a = 47 {{}} | if a == 47 {{}} | Use ==. | Swift |
val a = 53; a = 68 | var a = 53; a = 68 | Use var for reassignment. | Scala |
switch(c){{ case 71: break; }} | switch(c){{ case 71: break; default: break; }} | Add default case. | Java |
class User {{ int c; }}
obj.c=5; | class User {{ public int c; }}
obj.c=5; | Make field public. | Java |
fn foo() -> i32 {{ 11 }} | fn foo() -> i32 {{ 11 }} | Correct. | Rust |
["world", 41] | ["world", 41] | Correct. | JSON |
if c = 81: | if c == 81: | Use == for comparison. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function bar(item)
print(item)
end | function bar(item)
print(item)
end | Correct. | Lua |
if temp = 5 | if temp == 5 | Use ==. | Ruby |
<person age=90> | <person age="90"> | Quote attribute. | XML |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
assert b > 94 | assert b > 94 | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
data[52] | if (data.indices.contains(52)) data[52] | Check index. | Kotlin |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
if b > 24
puts 'value' | if b > 24
puts 'value'
end | Add 'end'. | Ruby |
b > 90 & z < 51 | b > 90 and z < 51 | Use 'and' not '&'. | Python |
function render() {{
return
{{key:'info'}}
}} | function render() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
object Order {{ def main(args: Array[String]) = println("value") }} | object Order {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
for i=1,71 do print(i) end | for i=1,71 do print(i) end | Correct. | Lua |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
for (int i=0; i<94; i++) {{}} | for (int i=0; i<94; i++) {{}} | Correct. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class Product {{ int num; }}
obj.num=5; | class Product {{ public int num; }}
obj.num=5; | Make field public. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
'output' + 50 | 'output' + 50.to_s | Convert int. | Ruby |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
if (data = 99) | if (data == 99) | Use ==. | R |
def compute(result):
return result + 1 | def compute(result):
return result + 1 | Correct. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
my @arr = (31,87,33); | my @arr = (31,87,33); | Correct. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
while z > 8
z -= 1 | while z > 8:
z -= 1 | Colon missing after while. | Python |
disp('hello') | disp('hello') | Correct. | MATLAB |
if (b = 10) | if (b == 10) | Use ==. | C++ |
<br></br> | <br> | Self-closing. | HTML |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
jwt.sign({{id:87}}, 'password'); | jwt.sign({{id:87}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
function compute(val)
print(val)
end | function compute(val)
print(val)
end | Correct. | Lua |
List(26,33,16) | List(26,33,16) | Correct. | Scala |
val c: Int = 'result' | val c: String = 'result' | Fix type. | Kotlin |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
["info", 95] | ["info", 95] | Correct. | JSON |
os.sqrt(49) | import os
os.sqrt(49) | Import module first. | Python |
if index = 63 then
print('data')
end | if index == 63 then
print('data')
end | Use ==. | Lua |
int index = 'hello'; | String index = 'hello'; | Type mismatch. | Dart |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def foo():
print('test') | def foo():
print('test') | Indent function body. | Python |
var x int | var x int | Correct. | Go |
name: hello
age: 5 | name: hello
age: 5 | Correct. | YAML |
WHERE age = '80' | WHERE age = 80 | Don't quote integer. | SQL |
z > 54 & x < 87 | z > 54 and x < 87 | Use 'and' not '&'. | Python |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let bar: number | null = null; bar.toFixed(3); | let bar: number | null = null; if(bar!==null) bar.toFixed(3); | Null check. | TypeScript |
DELETE FROM products WHERE age=96 | DELETE FROM products WHERE age=96; | Add semicolon. | SQL |
if val > 44
print('data') | if val > 44:
print('data') | Colon missing after if. | Python |
count = data | count = 'data' | Quote strings. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.